diff --git a/assets/index-80f2a537.css b/assets/index-80f2a537.css new file mode 100644 index 0000000..18f67a2 --- /dev/null +++ b/assets/index-80f2a537.css @@ -0,0 +1 @@ +h1{font-family:sans-serif}body{display:flex;flex-direction:column;margin:0;background-color:#2196f3;height:100%}.output{box-sizing:border-box;background:#d9dbda;margin:10px;height:20vh;padding:10px}main{display:flex;height:60vh;width:95vw;background-color:#ddc8f5}.resizeBar{width:5px;cursor:col-resize;background-color:#7e0eff}#blocklyDiv,.codeEditor{flex:1}.menuButtons{list-style-type:none;margin:0;padding:0;overflow:hidden}.menuButtons li{float:right}.dropdown-content{display:none;position:absolute;background-color:#f9f9f9;min-width:160px;box-shadow:0 8px 16px #0003;z-index:1;right:0}.dropdown-content a{color:#000;padding:12px 16px;text-decoration:none;display:block;white-space:nowrap}.button-text{display:none}.run-button:hover .button-text{display:inline}.run-button:before{content:"";position:absolute;width:0;height:0;border-top:10px solid transparent;border-bottom:10px solid transparent;border-left:15px solid white;left:40%;top:50%;transform:translateY(-50%);transition:none}.run-button:hover:before{display:none}.modal{display:none;position:fixed;z-index:99;padding-top:100px;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:#000;background-color:#0006}.tab{overflow:hidden;border:1px solid #ccc;background-color:#f1f1f1}.tab button{background-color:inherit;float:left;border:none;outline:none;cursor:pointer;padding:14px 16px;transition:.3s}.tab button:hover{background-color:#ddd}.tab button.active{background-color:#ccc}.tabcontent{display:none;padding:6px 12px;border:1px solid #ccc;border-top:none;animation:fadeEffect 1s}@keyframes fadeEffect{0%{opacity:0}to{opacity:1}}.modal-content{background-color:#fefefe;margin:auto;padding:20px;border:1px solid #888;width:80%}.close{color:#aaa;float:right;font-size:28px;font-weight:700}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer}#helpMenu{list-style-type:none;margin:0;padding:0;background-color:#f8f8f8;display:flex}.helpMenuButtons{border:none;padding:10px 20px;cursor:pointer;font-size:18px;margin:0 5px;transition:background-color .3s;font-family:Arial,sans-serif;border-radius:15px}.helpMenuButtons:hover{background-color:#ddd}#FeaturesButton{background-color:#4caf50;color:#fff}#ChangelogButton{background-color:#2196f3;color:#fff}#BugButton{background-color:#f44336;color:#fff}#GitHubButton{background-color:#673ab7;color:#fff}#AboutButton{background-color:#ff5722;color:#fff}#exampleTable{color:#2196f3;background-color:#e7e5e5;display:flex}.example_links{color:#00f;background:none;border:none;padding:0;margin:10px;cursor:pointer;color:inherit;text-decoration:underline}#secondary_bar{display:flex;background-color:#e7e5e5;border-style:solid;border-color:#aaa} diff --git a/assets/index-6d387683.js b/assets/index-ca413d27.js similarity index 66% rename from assets/index-6d387683.js rename to assets/index-ca413d27.js index 3fe0869..ae9243d 100644 --- a/assets/index-6d387683.js +++ b/assets/index-ca413d27.js @@ -1,13 +1,13 @@ -var L_=Object.defineProperty;var M_=(y,$,r)=>$ in y?L_(y,$,{enumerable:!0,configurable:!0,writable:!0,value:r}):y[$]=r;var qe=(y,$,r)=>(M_(y,typeof $!="symbol"?$+"":$,r),r);(function(){const $=document.createElement("link").relList;if($&&$.supports&&$.supports("modulepreload"))return;for(const m of document.querySelectorAll('link[rel="modulepreload"]'))p(m);new MutationObserver(m=>{for(const B of m)if(B.type==="childList")for(const P of B.addedNodes)P.tagName==="LINK"&&P.rel==="modulepreload"&&p(P)}).observe(document,{childList:!0,subtree:!0});function r(m){const B={};return m.integrity&&(B.integrity=m.integrity),m.referrerPolicy&&(B.referrerPolicy=m.referrerPolicy),m.crossOrigin==="use-credentials"?B.credentials="include":m.crossOrigin==="anonymous"?B.credentials="omit":B.credentials="same-origin",B}function p(m){if(m.ep)return;m.ep=!0;const B=r(m);fetch(m.href,B)}})();var si=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tm(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var Em={exports:{}},au={exports:{}},cu={exports:{}},hu={exports:{}},uu={exports:{}},am;function $u(){return am||(am=1,function(y,$){(function(r,p){y.exports=p()})(si,function(){var r={},p,m,B,P,C,f,a,s,o,c,l,h,d,g,_,v,k,I,S,b,x,N,D,R,w,F,A,T,L,O,H,V,W,K,Q,ie,J,Y,z,oe,he,de,fe,le,Re,Ke,vt,nt,Ue,De,Pt,Ct,ee,Te,Ti,xe,ae,ue,be,Ne,Be,He,Qe,Ve,M,U,j,ne,se,Fe,gn,Eu,Xr,bu,yl,Fn,yu,Yr,wu,Kr,wl,Sl,Su,jr,Gn,Il,Jr,Iu,Rl,Cl,Ru,Cu,fn,Ls,Ms,ku,Zr,kl,Ei,bi,Ns,Un,Al,Au,Ou,Lu,Mu,ve,kt,je,Ds,Bi,mn,xs,qt,Ol,Bs,Nu,Ll,yi,Du,Zi,Ml,Nl,Qr,Dl,ei,Ps,xl,qr,eo,Bl,xu,Pl,Fs,Bu,Pu,Qi,Fl,wi,Fu,Gu,Uu,Hn,Hu,_n,Gl,Vu,Wu,zu,Xu,Yu,Ul,Ku,ju,to,Ju,Zu,Hl,io,Qu,Si,qu,ed,td,id,nd,sd,rd,Vl,qi,no,Wl,od,ld,ad,cd,hd,ud,dd,pd,zl,gd,fd,md,_d,Vn,Xl,Wn,Yl,Kl,jl,zn,so,ro,$d,Gs,Jl,Zl,Ql,ql,ea,ta,vd,Us,ia,Xn,oo,oi,na,Td,Ed,Hs,sa,ra,oa,bd,lo,la,yd,aa,wd,Sd,Id,Rd,Yn,ca,ha,Vs,ua,Cd,kd,da,pa,en,ga,fa,Ad,Od,Ld,Md,ma,Nd,_a,Dd,tn,Ws,ao,co,$n,ho,uo,po,rt,zs,vn,Tn,xd,$a,go,li,va,fo,Ta,Ea,Bd,Pd,Xt,Fd,mo,Gd,ai,st,Ud,Hd,ba,Vd,Wd,Pi,zd,Xs,Xd,Ys,_o,Yd,$o,Kd,vo,ya,wa,jd,Jd,Sa,To,Zd,Qd,qd,Ia,Eo,Ra,bo,ep,Ks,tp,ip,At,Ca,ka,Aa,Oa,La,Ma,Kn,js,Na,np,yo,sp,jn,rp,wo,Js,op,lp,Da,Zs,ap,cp,hp,up,Qs,xa,dp,Ba,Pa,pp,qs,Ee,Ft,yt,tt,Ii,Jn,_e,ht,gp,Fa,fp,Ga,Ua,Ha,Va,Wa,za,Xa,Ya,Ka,ja,So,er,Ja,mp,Za,Qa,qa,ec,tc,ic,nc,_p,sc,nn,Io,Ro,rc,oc,$p,lc,vp,Co,ac,cc,Tp,hc,Ep,bp,yp,uc,tr,wp,Zn,Sp,Ip,dc,pc,gc,fc,ko,mc,Ao,Oo,Lo,Rp,Cp,kp,Ap,Op,Lp,Mp,Np,_c,$c,vc,Tc,Dp,xp,Ec,bc,yc,wc,Sc,Ic,Rc,Cc,Bp,Pp,Fp,Gp,Up,Hp,Vp,Wp,zp,Xp,Yp,Kp,jp,Jp,Zp,Qp,qp,eg,tg,ig,ng,sg,rg,og,ye;p=function(e,t,i,n){e=e+" was deprecated in "+t+" and will be deleted in "+i+".",n&&(e+=` -Use `+n+" instead."),console.warn(e)},m=function(e,t,i,n){if(!(e instanceof pe)&&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 u=t.toLowerCase();if(!i)throw Error("Can not register a null value");let E=sn[e],G=Mo[e];if(E||(E=sn[e]=Object.create(null),G=Mo[e]=Object.create(null)),B(e,i),!n&&E[u])throw Error('Name "'+u+'" with type "'+e+'" already registered.');E[u]=i,G[u]=t},B=function(e,t){switch(e){case String(pe.FIELD):if(typeof t.fromJson!="function")throw Error('Type "'+e+'" must have a fromJson function')}},P=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();const i=sn[e];i&&i[t]?(delete sn[e][t],delete Mo[e][t]):console.warn("Unable to unregister ["+t+"]["+e+"] from the registry.")},C=function(e,t,i){e=`${e}`.toLowerCase(),t=t.toLowerCase();const n=sn[e];if(!n||!n[t]){if(t="Unable to find ["+t+"]["+e+"] in the registry.",i)throw Error(t+" You must require or register a "+e+" plugin.");return console.warn(t),null}return n[t]},f=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),(e=sn[e])?!!e[t]:!1},a=function(e,t,i){return C(e,t,i)},s=function(e,t,i){return C(e,t,i)},o=function(e,t,i){e=`${e}`.toLowerCase();var n=sn[e];if(!n){if(n=`Unable to find [${e}] in the registry.`,i)throw Error(`${n} You must require or register a ${e} plugin.`);return console.warn(n),null}if(!t)return n;e=Mo[e],i=Object.create(null);for(const u of Object.keys(n))i[e[u]]=n[u];return i},c=function(e,t,i){return t=t.plugins[String(e)]||Fi,typeof t=="function"?t:a(e,t,i)},l=function(e){return Qn[e]||null},h=function(){const e=[];for(const t in Qn)e.push(Qn[t]);return e},d=function(e){Qn[e.id]=e},g=function(e){delete Qn[e.id]},_=function(){return lg},v=function(e){lg=e},k=function(){return kc},I=function(e){kc=e},S=function(){return ag},b=function(e){ag=e},x=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;const t=e.getParentSvg(),i=e.getCachedParentSvgSize();var n=t.parentElement;if(n instanceof HTMLElement){var u=n.offsetWidth;n=n.offsetHeight,i.width!==u&&(t.setAttribute("width",u+"px"),e.setCachedParentSvgSize(u,null)),i.height!==n&&(t.setAttribute("height",n+"px"),e.setCachedParentSvgSize(null,n)),e.resize()}},N=function(e,t){const i=Object.create(null),n=e.getDescendants(!0);t&&(e=e.getNextBlock())&&(e=n.indexOf(e),n.splice(e,n.length-e));for(let u=0,E;E=n[u];u++)i[E.type]?i[E.type]++:i[E.type]=1;return i},D=function(e){return function(){this.jsonInit(e)}},R=function(e){Ac.defineBlocksWithJsonArrayInternal(e)},w=function(e){r.defineBlocks$$module$build$src$core$common(r.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(e))},r.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(e){const t={};for(let i=0;i{setTimeout(V,0)})}catch{setTimeout(V,0)}ns.push(e)}},V=function(){const e=W(ns,!0);ns.length=0;for(let t=0,i;i=e[t];t++){if(!i.workspaceId)continue;const n=l(i.workspaceId);n&&n.fireChangeListener(i)}},W=function(e,t){e=e.slice(),t||e.reverse();const i=[],n=Object.create(null);for(let G=0,X;X=e[G];G++)if(!X.isNull()){var u=[X.isUiEvent?sr:X.type,X.blockId,X.workspaceId].join(" "),E=n[u];const re=E?E.event:null;E?X.type===Ot&&E.index===G-1?(u=X,re.newParentId=u.newParentId,re.newInputName=u.newInputName,re.newCoordinate=u.newCoordinate,E.index=G):X.type===$t&&X.element===re.element&&X.name===re.name?re.newValue=X.newValue:X.type===yn?(E=X,re.viewTop=E.viewTop,re.viewLeft=E.viewLeft,re.scale=E.scale,re.oldScale=E.oldScale):(X.type!==on||re.type!==Gi)&&(n[u]={event:X,index:G},i.push(X)):(n[u]={event:X,index:G},i.push(X))}e=i.filter(function(G){return!G.isNull()}),t||e.reverse();for(let G=1,X;X=e[G];G++)X.type===$t&&X.element==="mutation"&&e.unshift(e.splice(G,1)[0]);return e},K=function(){for(let e=0,t;t=ns[e];e++)t.recordUndo=!1},Q=function(){Oc++},ie=function(){Oc--},J=function(){return Oc===0},Y=function(){return ug},z=function(e){Mc.setGroupInternal(e)},oe=function(e){ug=typeof e=="boolean"?e?A():"":e},he=function(e){const t=[];e=e.getDescendants(!1);for(let i=0,n;n=e[i];i++)t[i]=n.id;return t},de=function(e,t){var i=le(e.type);if(!i)throw Error("Unknown event type.");return fe(i)?i.fromJson(e,t):(i=new i,i.fromJson(e),i.workspaceId=t.id,i)},fe=function(e){return Object.getOwnPropertyDescriptors(e).fromJson&&typeof e.fromJson=="function"},le=function(e){const t=a(pe.EVENT,e);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},Re=function(e){if((e.type===Ot||e.type===wt)&&e.workspaceId){var t=l(e.workspaceId);if(!e.blockId)throw Error("Encountered a blockEvent without a proper blockId");if(e=t.getBlockById(e.blockId)){const i=ir;try{ir=!1;const n=e.getParent();if(n&&n.isEnabled()){const u=e.getDescendants(!1);for(let E=0,G;G=u[E];E++)G.setEnabled(!0)}else if((e.outputConnection||e.previousConnection)&&!t.isDragging())do e.setEnabled(!1),e=e.getNextBlock();while(e)}finally{ir=i}}}},Ke=function(e){({document:Sn=Sn,DOMParser:Do=Do,XMLSerializer:xo=xo}=e)},vt=function(){return p("Blockly.utils.xml.getDocument","version 9","version 10"),Sn},nt=function(e){p("Blockly.utils.xml.setDocument","version 9","version 10"),Sn=e},r.createElement$$module$build$src$core$utils$xml=function(e){return Sn.createElementNS(Nc,e)},Ue=function(e){return Sn.createTextNode(e)},De=function(e){const t=Pt(e);if(!t||!t.documentElement||t.getElementsByTagName("parsererror").length)throw Error("textToDom was unable to parse: "+e);return t.documentElement},Pt=function(e){return new Do().parseFromString(e,"text/xml")},Ct=function(e){return new xo().serializeToString(e)},ee=function(e,t,i){e=document.createElementNS(ss,`${e}`);for(const n in t)e.setAttribute(n,`${t[n]}`);return i&&i.appendChild(e),e},Te=function(e,t){return t=t.split(" "),t.every(i=>e.classList.contains(i))?!1:(e.classList.add(...t),!0)},Ti=function(e,t){e.classList.remove(...t.split(" "))},xe=function(e,t){return t=t.split(" "),t.every(i=>!e.classList.contains(i))?!1:(e.classList.remove(...t),!0)},ae=function(e,t){return e.classList.contains(t)},ue=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},be=function(e,t){const i=t.nextSibling;if(t=t.parentNode,!t)throw Error("Reference node has no parent.");i?t.insertBefore(e,i):t.appendChild(e)},Ne=function(e,t){return!!(e.compareDocumentPosition(t)&Ci.DOCUMENT_POSITION_CONTAINED_BY)},Be=function(e,t){e.style.transform=t,e.style["-webkit-transform"]=t},He=function(){Dc++,ui||(ui=Object.create(null))},Qe=function(){Dc--,Dc||(ui=null)},Ve=function(e){const t=e.textContent+` -`+e.className.baseVal;let i;if(ui&&(i=ui[t]))return i;try{i=e.getComputedTextLength()}catch{return 8*e.textContent.length}return ui&&(ui[t]=i),i},M=function(e,t,i,n){return U(e,t+"pt",i,n)},U=function(e,t,i,n){const u=e.textContent;e=u+` -`+e.className.baseVal;var E;return ui&&(E=ui[e])||(Bo||(E=document.createElement("canvas"),E.className="blocklyComputeCanvas",document.body.appendChild(E),Bo=E.getContext("2d")),Bo.font=i+" "+t+" "+n,E=u?Bo.measureText(u).width:0,ui&&(ui[e]=E)),E},j=function(e,t,i,n){const u=document.createElement("span");u.style.font=i+" "+t+" "+n,u.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(u),t.appendChild(e),document.body.appendChild(t),i={height:0,baseline:0};try{t.style.alignItems="baseline",i.baseline=e.offsetTop-u.offsetTop,t.style.alignItems="flex-end",i.height=e.offsetTop-u.offsetTop}finally{document.body.removeChild(t)}return i},ne=function(e,t){dg(e,t)},se=function(e){dg=e},Fe=function(e,t){fg.confirmInternal(e,t)},gn=function(e,t){pg(e,t)},Eu=function(e){pg=e},Xr=function(e,t,i){gg(e,t,i)},bu=function(e){gg=e},yl=function(e){return e.getVariableModel!==void 0},Fn=function(e){return e.getProcedureDef!==void 0},yu=function(e){return e.getProcedureCall!==void 0&&e.renameProcedure!==void 0},Yr=function(e){e=e.getAllBlocks(!1);const t=new Set;for(let i=0;i1'),n.appendChild(i),t.push(n)),Ut.variables_get){e.sort(ur.compareByName);for(let u=0,E;E=e[u];u++)i=r.createElement$$module$build$src$core$utils$xml("block"),i.setAttribute("type","variables_get"),i.setAttribute("gap","8"),i.appendChild(fn(E)),t.push(i)}}return t},Sl=function(e){return Pc.generateUniqueNameInternal(e)},Su=function(e){return jr(Fo.charAt(0),e.getAllVariableNames())},jr=function(e,t){if(!t.length)return e;const i=Fo;let n="",u=i.indexOf(e);for(;;){let E=!1;for(let G=0;GE.getVariableModel().name);if(n&&(i=n.some(E=>E.toLowerCase()===e),n=n.some(E=>E.toLowerCase()===t),i&&n))return u.getName()}return null},Cu=function(e,t,i){e=e.toLowerCase(),t=t.toLowerCase(),i=i.getAllBlocks(!1);for(const u of i){if(!Fn(u))continue;i=u.getProcedureDef();var n=i[1];const E=n.some(G=>G.toLowerCase()===e);if(n=n.some(G=>G.toLowerCase()===t),E&&n)return i[0]}return null},fn=function(e){const t=r.createElement$$module$build$src$core$utils$xml("field");return t.setAttribute("name","VAR"),t.setAttribute("id",e.getId()),t.setAttribute("variabletype",e.type),e=Ue(e.name),t.appendChild(e),t},Ls=function(e,t,i,n){let u=Ms(e,t,i,n);return u||(u=ku(e,t,i,n)),u},Ms=function(e,t,i,n){const u=e.getPotentialVariableMap();let E=null;if(t&&(E=e.getVariableById(t),!E&&u&&(E=u.getVariableById(t)),E))return E;if(i){if(n===void 0)throw Error("Tried to look up a variable by name without a type");E=e.getVariable(i,n),!E&&u&&(E=u.getVariable(i,n))}return E},ku=function(e,t,i,n){const u=e.getPotentialVariableMap();return i||(i=Sl(e.isFlyout?e.targetWorkspace:e)),u?u.createVariable(i,n,t):e.createVariable(i,n,t)},Zr=function(e,t){e=e.getAllVariables();const i=[];if(t.length!==e.length)for(let n=0;n>>/g,e),Xc="",e=document.createElement("style"),e.id="blockly-common-style",t=document.createTextNode(t),e.appendChild(t),document.head.insertBefore(e,document.head.firstChild)))},Bs=function(e){return Rg.getSizeInternal(e)},Nu=function(e){if(yi(e,"display")!=="none")return Ll(e);const t=e.style,i=t.display,n=t.visibility,u=t.position;t.visibility="hidden",t.position="absolute",t.display="inline";const E=e.offsetWidth;return e=e.offsetHeight,t.display=i,t.position=u,t.visibility=n,new Tt(E,e)},Ll=function(e){return new Tt(e.offsetWidth,e.offsetHeight)},yi=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},Du=function(e,t){return p("Blockly.utils.style.getCascadedStyle","version 9","version 10"),e.currentStyle?e.currentStyle[t]:""},Zi=function(e){const t=new ge(0,0);e=e.getBoundingClientRect();var i=document.documentElement;return i=new ge(window.pageXOffset||i.scrollLeft,window.pageYOffset||i.scrollTop),t.x=e.left+i.x,t.y=e.top+i.y,t},Ml=function(){const e=document.body,t=document.documentElement;return new ge(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},Nl=function(e){const t=parseFloat(yi(e,"borderLeftWidth")),i=parseFloat(yi(e,"borderRightWidth")),n=parseFloat(yi(e,"borderTopWidth"));return e=parseFloat(yi(e,"borderBottomWidth")),new ct(n,e,t,i)},Qr=function(e,t,i){e=Dl(e,t,i),t.scrollLeft=e.x,t.scrollTop=e.y},Dl=function(e,t,i){var n=Zi(e),u=Zi(t),E=Nl(t);const G=n.x-u.x-E.left;return n=n.y-u.y-E.top,u=Ll(e),e=t.clientWidth-u.width,u=t.clientHeight-u.height,E=t.scrollLeft,t=t.scrollTop,i?(E+=G-e/2,t+=n-u/2):(E+=Math.min(G,Math.max(G-e,0)),t+=Math.min(n,Math.max(n-u,0))),new ge(E,t)},ei=function(e){const t=new ge(0,0);var i=e.x&&e.getAttribute("x");const n=e.y&&e.getAttribute("y");return i&&(t.x=parseInt(i)),n&&(t.y=parseInt(n)),(i=(i=e.getAttribute("transform"))&&i.match(Cg))&&(t.x+=Number(i[1]),i[3]&&(t.y+=Number(i[3]))),(e=e.getAttribute("style"))&&-1/g,"<$1$2>")},Fu=function(e){e=wi(e).split("<");let t="";for(let i=1;i"&&(t+=" ")}return e=e.join(` -`),e=e.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1"),e.replace(/^\n/,"")},Gu=function(e){return p("Blockly.Xml.textToDom","version 9","version 10","Use Blockly.utils.xml.textToDom instead"),De(e)},Uu=function(e,t){return t.setResizesEnabled(!1),t.clear(),e=Hn(e,t),t.setResizesEnabled(!0),e},Hn=function(e,t){let i=0;t.RTL&&(i=t.getWidth());const n=[];He();const u=Y();u||z(!0),t.setResizesEnabled&&t.setResizesEnabled(!1);let E=!0;try{for(let G=0,X;X=e.childNodes[G];G++){const re=X.nodeName.toLowerCase(),me=X;if(re==="block"||re==="shadow"&&!L()){const lt=_n(me,t);n.push(lt.id);let at;const zt=parseInt((at=me.getAttribute("x"))!=null?at:"10",10);let Cs;const ks=parseInt((Cs=me.getAttribute("y"))!=null?Cs:"10",10);isNaN(zt)||isNaN(ks)||lt.moveBy(t.RTL?i-zt:zt,ks),E=!1}else{if(re==="shadow")throw TypeError("Shadow block cannot be a top-level block.");if(re==="comment")t.rendered?St.fromXmlRendered(me,t,i):ki.fromXml(me,t);else if(re==="variables"){if(E)Gl(me,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.");E=!1}}}}finally{z(u),Qe()}return t.setResizesEnabled&&t.setResizesEnabled(!0),O(new(le(is))(t)),n},Hu=function(e,t){if(!t.getBlocksBoundingBox)return Hn(e,t);var i=t.getBlocksBoundingBox();if(e=Hn(e,t),i&&i.top!==i.bottom){var n=i.bottom;i=t.RTL?i.right:i.left;var u=1/0;let E=-1/0,G=1/0;for(let X=0;XE&&(E=re.x)}for(n=n-G+10,i=t.RTL?i-E:i-u,u=0;u{G.disposed||G.setConnectionTracking(!0)},1),G},Wl=function(e,t,{parentConnection:i,isShadow:n=!1}={}){if(!e.type)throw new Ag(e);const u=t.newBlock(e.type,e.id);return u.setShadow(n),od(u,e),ld(u,e),ad(u,e),cd(i,u,e),hd(u,e),ud(u,e),dd(u,e),pd(u,e),gd(u,t.rendered),u},od=function(e,t){let i=t.x===void 0?0:t.x;t=t.y===void 0?0:t.y;const n=e.workspace;i=n.RTL?n.getWidth()-i:i,e.moveBy(i,t)},ld=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)},ad=function(e,t){t.extraState&&(e.loadExtraState?e.loadExtraState(t.extraState):e.domToMutation&&e.domToMutation(De(t.extraState)))},cd=function(e,t,i){if(e){if(e.getSourceBlock().isShadow()&&!t.isShadow())throw new Lg(i);if(e.type===Ae.VALUE){var n=t.outputConnection;if(!n)throw new pr("output",t,i)}else if(n=t.previousConnection,!n)throw new pr("previous",t,i);if(!e.connect(n)){const u=t.workspace.connectionChecker;throw new Og(u.getErrorMessage(u.canConnectWithReason(n,e,!1),n,e),e.type===Ae.VALUE?"output connection":"previous connection",t,i)}}},hd=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 Tt(t.width,t.height)),t.pinned&&e.rendered&&!e.isInFlyout&&setTimeout(()=>e.getCommentIcon().setVisible(!0),1))},ud=function(e,t){if(t.fields){var i=Object.keys(t.fields);for(let n=0;nt&&(t=i[n].length);var u=-1/0;let E,G=1;do{n=u,E=e,e=[],u=i.length/G;let X=1;for(let re=0;ren);return E},lo=function(e,t,i){const n=[0],u=[];for(var E=0;En&&(n=X,u=G)}return u?la(e,u,i):t},yd=function(e,t){const i=[];for(let n=0;nVg&&en()}else $r!==ti&&(clearTimeout(An),nh=e.pageX,sh=e.pageY,An=setTimeout(Md,Wg))},pa=function(){$r=ti=null,en()},en=function(){_r&&(_r=!1,gt&&(gt.style.display="none")),An&&(clearTimeout(An),An=0)},ga=function(){en(),ps=!0},fa=function(){ps=!1},Ad=function(){gt&&ti&&(typeof Jo=="function"?Jo(gt,ti):Od())},Od=function(){var e=Yn(ti);e=oa(e,Ug),e=e.split(` -`);for(let t=0;ti+window.scrollY&&(u-=gt.offsetHeight+2*oh),e?n=Math.max(Zo-window.scrollX,n):n+gt.offsetWidth>t+window.scrollX-2*Zo&&(n=t-gt.offsetWidth-2*Zo),{x:n,y:u}},Md=function(){if(!ps&&($r=ti,gt)){gt.textContent="",Ad();var e=ti.RTL;gt.style.direction=e?"rtl":"ltr",gt.style.display="block",_r=!0;var{x:t,y:i}=Ld(e);gt.style.left=t+"px",gt.style.top=i+"px"}},ma=function(){return lh},Nd=function(e){lh=e},_a=function(){return ah},Dd=function(e){ah=e},tn=function(e){e=`${e}`.toLowerCase().trim();var t=zg[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 i=e.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return i&&(e=Number(i[1]),t=Number(i[2]),i=Number(i[3]),0<=e&&256>e&&0<=t&&256>t&&0<=i&&256>i)?Ws(e,t,i):null},Ws=function(e,t,i){return t=e<<16|t<<8|i,16>e?"#"+(16777216|t).toString(16).substr(1):"#"+t.toString(16)},ao=function(e){return e=tn(e),e?(e=parseInt(e.substr(1),16),[e>>16,e>>8&255,e&255]):[0,0,0]},co=function(e,t,i){let n=0,u=0,E=0;if(t===0)E=u=n=i;else{const G=Math.floor(e/60),X=e/60-G;e=i*(1-t);const re=i*(1-t*X);switch(t=i*(1-t*(1-X)),G){case 1:n=re,u=i,E=e;break;case 2:n=e,u=i,E=t;break;case 3:n=e,u=re,E=i;break;case 4:n=t,u=e,E=i;break;case 5:n=i,u=e,E=re;break;case 6:case 0:n=i,u=t,E=e}}return Ws(Math.floor(n),Math.floor(u),Math.floor(E))},$n=function(e,t,i){return e=tn(e),!e||(t=tn(t),!t)?null:(e=ao(e),t=ao(t),Ws(Math.round(t[0]+i*(e[0]-t[0])),Math.round(t[1]+i*(e[1]-t[1])),Math.round(t[2]+i*(e[2]-t[2]))))},ho=function(e){return co(e,lh,255*ah)},uo=function(e,t){const i=[];var n=e.split("");n.push("");var u=0;e=[];let E=null;for(let re=0;re=G?(u=2,E=G,(G=e.join(""))&&i.push(G),e.length=0):G==="{"?u=3:(e.push("%",G),u=0);else if(u===2)if("0"<=G&&"9">=G)E+=G;else{var X=void 0;i.push(parseInt((X=E)!=null?X:"",10)),re--,u=0}else u===3&&(G===""?(e.splice(0,0,"%{"),re--,u=0):G!=="}"?e.push(G):(u=e.join(""),/[A-Z]\w*/i.test(u)?(G=u.toUpperCase(),(G=G.startsWith("BKY_")?G.substring(4):null)&&G in Ie?(u=Ie[G],typeof u=="string"?Array.prototype.push.apply(i,uo(u,t)):t?i.push(`${u}`):i.push(u)):i.push("%{"+u+"}")):i.push("%{"+u+"}"),u=e.length=0))}for((t=e.join(""))&&i.push(t),X=[],e.length=0,n=0;n=i)return{hue:i,hex:co(i,ma(),255*_a())};if(i=tn(t))return{hue:null,hex:i};throw i='Invalid colour: "'+t+'"',e!==t&&(i+=' (from "'+e+'")'),Error(i)},Tn=function(){return pi},xd=function(e){pi=e},$a=function(){pi||(pi=document.createElement("div"),pi.className="blocklyWidgetDiv",(S()||document.body).appendChild(pi))},go=function(e,t,i){li(),Qo=e,qo=i,(e=pi)&&(e.style.direction=t?"rtl":"ltr",e.style.display="block",t=_(),gs=t.getRenderer().getClassName(),fs=t.getTheme().getClassName(),gs&&Te(e,gs),fs&&Te(e,fs))},li=function(){if(va()){Qo=null;var e=pi;e&&(e.style.display="none",e.style.left="",e.style.top="",qo&&qo(),qo=null,e.textContent="",gs&&(xe(e,gs),gs=""),fs&&(xe(e,fs),fs=""),_().markFocused())}},va=function(){return!!Qo},fo=function(e){Qo===e&&li()},Ta=function(e,t,i){pi.style.left=e+"px",pi.style.top=t+"px",pi.style.height=i+"px"},Ea=function(e,t,i,n){const u=Pd(e,t,i);e=Bd(e,t,i,n),0>u?Ta(e,0,i.height+u):Ta(e,u,i.height)},Bd=function(e,t,i,n){return n?Math.min(Math.max(t.right-i.width,e.left),e.right-i.width):Math.max(Math.min(t.left,e.right-i.width),e.left)},Pd=function(e,t,i){return t.bottom+i.height>=e.bottom?t.top-i.height:t.bottom},Xt=function(e,t){m(pe.FIELD,e,t)},Fd=function(e){P(pe.FIELD,e)},mo=function(e){return ch.fromJsonInternal(e)},Gd=function(e){const t=s(pe.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},ai=function(e,t){e.setAttribute(Xm,t)},st=function(e,t,i){Array.isArray(i)&&(i=i.join(" ")),e.setAttribute(zm+t,`${i}`)},Ud=function(e){let t=!1;const i=e.map(([G,X])=>typeof G=="string"?[rt(G),X]:(t=!0,[G.alt!==null?Object.assign({},G,{alt:rt(G.alt)}):Object.assign({},G),X]));if(t||2>e.length)return{options:i};var n=i.map(([G])=>G),u=Hs(n);e=sa(n,u);const E=ra(n,u);return!e&&!E||u<=e+E?{options:i}:(u=e?n[0].substring(0,e-1):void 0,n=E?n[0].substr(1-E):void 0,{options:Hd(i,e,E),prefix:u,suffix:n})},Hd=function(e,t,i){return e.map(([n,u])=>[n.substring(t,n.length-i),u])},ba=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 i=0;i document.")}else e instanceof Element&&(t=e);return t},r.register$$module$build$src$core$extensions=function(e,t){if(typeof e!="string"||e.trim()==="")throw Error('Error: Invalid extension name "'+e+'"');if(ms[e])throw Error('Error: Extension "'+e+'" is already registered.');if(typeof t!="function")throw Error('Error: Extension "'+e+'" must be a function');ms[e]=t},jd=function(e,t){if(!t||typeof t!="object")throw Error('Error: Mixin "'+e+'" must be a object');r.register$$module$build$src$core$extensions(e,function(){this.mixin(t)})},r.registerMutator$$module$build$src$core$extensions=function(e,t,i,n){const u='Error when registering mutator "'+e+'": ';Ra(u,t);const E=Ia(t,u);if(i&&typeof i!="function")throw Error(u+'Extension "'+e+'" is not a function');r.register$$module$build$src$core$extensions(e,function(){E&&this.setMutator(new r.Mutator$$module$build$src$core$mutator(n||[],this)),this.mixin(t),i&&i.apply(this)})},Jd=function(e){Sa(e)?delete ms[e]:console.warn('No extension mapping for name "'+e+'" found to unregister')},Sa=function(e){return!!ms[e]},To=function(e,t,i){const n=ms[e];if(typeof n!="function")throw Error('Error: Extension "'+e+'" not found.');let u;if(i?Zd(e,t):u=bo(t),n.apply(t),i)Ra('Error after applying mutator "'+e+'": ',t);else if(!ep(u,t))throw Error('Error when applying extension "'+e+'": mutation properties changed when applying a non-mutator extension.')},Zd=function(e,t){if(bo(t).length)throw Error('Error: tried to apply mutation "'+e+'" to a block that already has mutator functions. Block id: '+t.id)},Qd=function(e,t){return Eo(e.mutationToDom,e.domToMutation,t+" mutationToDom/domToMutation")},qd=function(e,t){return Eo(e.saveExtraState,e.loadExtraState,t+" saveExtraState/loadExtraState")},Ia=function(e,t){return Eo(e.compose,e.decompose,t+" compose/decompose")},Eo=function(e,t,i){if(e&&t){if(typeof e!="function"||typeof t!="function")throw Error(i+" must be a function");return!0}if(!e&&!t)return!1;throw Error(i+"Must have both or neither functions")},Ra=function(e,t){const i=Qd(t,e),n=qd(t,e);if(!i&&!n)throw Error(e+"Mutations must contain either XML hooks, or JSON hooks, or both");Ia(t,e)},bo=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},ep=function(e,t){if(t=bo(t),t.length!==e.length)return!1;for(let i=0;ii)){var n=t.getSvgXY(e.getSvgRoot());e.outputConnection?(n.x+=(e.RTL?3:-3)*i,n.y+=13*i):e.previousConnection&&(n.x+=(e.RTL?-23:23)*i,n.y+=3*i),e=ee(q.CIRCLE,{cx:n.x,cy:n.y,r:0,fill:"none",stroke:"#888","stroke-width":10},t.getParentSvg()),Oa(e,new Date,i)}},Oa=function(e,t,i){const n=(new Date().getTime()-t.getTime())/150;1e.workspace.scale)){var t=e.getHeightWidth().height;t=Math.atan(10/t)/Math.PI*180,e.RTL||(t*=-1),yr=e,Ma(e,t,new Date)}},Ma=function(e,t,i){const n=(new Date().getTime()-i.getTime())/200;let u="";1>=n&&(u=`skewX(${Math.round(Math.sin(n*Math.PI*3)*(1-n)*t)})`,br=setTimeout(Ma,10,e,t,i)),e.getSvgRoot().setAttribute("transform",`${e.getTranslation()} ${u}`)},Kn=function(){yr&&(br&&(clearTimeout(br),br=null),yr.getSvgRoot().setAttribute("transform",yr.getTranslation()),yr=null)},js=function(e,t,i){const n=i.getBoundingRectangle(),u=n.right-n.left,E=Wn(t.top,n.top,t.top+t.height-(n.bottom-n.top))-n.top;let G=t.left;return t=t.left+t.width-u,e.RTL?G=Math.min(t,G):t=Math.max(G,t),(e=Wn(G,n.left,t)-n.left)||E?(i.moveBy(e,E),!0):!1},Na=function(e){return t=>{var i=e.getMetricsManager();if(i.hasFixedEdges()&&!e.isDragging()){var n;if(Lc.indexOf((n=t.type)!=null?n:"")!==-1){n=i.getScrollMetrics(!0);const u=np(e,t);u&&(i=Y()||!1,z(t.group),js(e,n,u)&&!t.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),z(i))}else t.type===yn&&t.scale&&t.oldScale&&t.scale>t.oldScale&&yo(e)}}},np=function(e,t){let i=null;switch(t.type){case wt:case Ot:(i=e.getBlockById(t.blockId))&&(i=i.getRootBlock());break;case wn:case Ui:i=e.getCommentById(t.commentId)}return i},yo=function(e){var t=e.getMetricsManager();if(t.hasFixedEdges()&&!e.isDragging()){t=t.getScrollMetrics(!0);var i=e.getTopBoundedElements();for(let n=0,u;u=i[n];n++)js(e,t,u)}},sp=function(e){const t=[];e=e.getDescendants(!1);for(let i=0,n;n=e[i];i++){const u=n.getIcons();for(let E=0;E{setTimeout(()=>{u.callback(u.scope)},0)})},{})}return i},cp=function(e,t,i){const n=qr();t=new ct(t.clientY+n.top,t.clientY+n.top,t.clientX+n.left,t.clientX+n.left),hp(e);const u=e.getSize();i&&(t.left+=u.width,t.right+=u.width,n.left+=u.width,n.right+=u.width),Ea(n,t,u,i),e.focus()},hp=function(e){var t=Tn();if(!t)throw Error("Attempting to create a context menu when widget div is null");t=e.render(t),Te(t,"blocklyContextMenu"),ve(t,"contextmenu",null,up),e.focus()},up=function(e){e.preventDefault(),e.stopPropagation()},Qs=function(){fo(vh),Ir=null},xa=function(){Rr&&(Rr.dispose(),Rr=null)},dp=function(e,t){return()=>{Q();let i;try{i=_n(t,e.workspace);const n=e.getRelativeToSurfaceXY();n.x=e.RTL?n.x-r.config$$module$build$src$core$config.snapRadius:n.x+r.config$$module$build$src$core$config.snapRadius,n.y+=2*r.config$$module$build$src$core$config.snapRadius,i.moveBy(n.x,n.y)}finally{ie()}J()&&!i.isShadow()&&O(new(le(wt))(i)),i.select()}},Ba=function(e){return{text:Ie.REMOVE_COMMENT,enabled:!0,callback:function(){z(!0),e.dispose(),z(!1)}}},Pa=function(e){return{text:Ie.DUPLICATE_COMMENT,enabled:!0,callback:function(){Js(e)}}},pp=function(e,t){const i={enabled:!0};return i.text=Ie.ADD_COMMENT,i.callback=function(){const n=new St(e,Ie.WORKSPACE_COMMENT_DEFAULT_TEXT,St.DEFAULT_SIZE,St.DEFAULT_SIZE);var u=e.getInjectionDiv().getBoundingClientRect();u=new ge(t.clientX-u.left,t.clientY-u.top);const E=e.getOriginOffsetInPixels();u=ge.difference(u,E),u.scale(1/e.scale),n.moveBy(u.x,u.y),e.rendered&&(n.initSvg(),n.render(),n.select())},i},qs=function(e){let t=e.outputConnection;return(!t||e.previousConnection&&e.previousConnection.isConnected())&&(t=e.previousConnection),t},Ee=function(e,t){return" "+e+","+t+" "},Ft=function(e,t){return" "+e+t.join("")},yt=function(e,t){return" M "+e+","+t+" "},tt=function(e,t){return" m "+e+","+t+" "},Ii=function(e,t){return" l "+e+","+t+" "},Jn=function(e){return" l"+e.join("")},_e=function(e,t){return" "+e+" "+t+" "},ht=function(e,t,i,n){return e+" "+i+" "+i+" "+t+n},gp=function(e){Fa(e),wh||(wh=window.requestAnimationFrame(fp))},Fa=function(e){sl.add(e);const t=e.getParent();t?Fa(t):nl.add(e)},fp=function(){const e=new Set([...nl].map(t=>t.workspace));for(const t of nl)t.isDisposed()||t.getParent()||(Ga(t),Ua(t,t.getRelativeToSurfaceXY()),Ha(t));for(const t of e)t.resizeContents();nl.clear(),sl=new Set,wh=0},Ga=function(e){if(sl.has(e)){for(const t of e.getChildren(!1))Ga(t);e.renderEfficiently()}},Ua=function(e,t){for(const i of e.getConnections_(!1)){e=i.moveToOffset(t);const n=i.targetBlock();i.isSuperior()&&n&&(e||sl.has(n))&&Ua(n,ge.sum(t,n.relativeCoords))}},Ha=function(e){if(e.getIcons){for(const t of e.getIcons())t.computeIconLocation();for(const t of e.getChildren(!1))Ha(t)}},Va=function(){Xe.registry.register({displayText(){return Ie.UNDO},preconditionFn(e){return 0t.length?er(t):Fe(Ie.DELETE_ALL_BLOCKS.replace("%1",String(t.length)),function(i){i&&er(t)})}},scopeType:Xe.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},mp=function(){Va(),Wa(),za(),Ya(),Ka(),Ja()},Za=function(){Xe.registry.register({displayText(){return Ie.DUPLICATE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.isDeletable()&&e.isMovable()?e.isDuplicatable()?"enabled":"disabled":"hidden"},callback(e){e.block&&Js(e.block)},scopeType:Xe.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},Qa=function(){Xe.registry.register({displayText(e){return e.block.getCommentIcon()?Ie.REMOVE_COMMENT:Ie.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:Xe.ScopeType.BLOCK,id:"blockComment",weight:2})},qa=function(){Xe.registry.register({displayText(e){return e.block.getInputsInline()?Ie.EXTERNAL_INPUTS:Ie.INLINE_INPUTS},preconditionFn(e){if(e=e.block,!e.isInFlyout&&e.isMovable()&&!e.isCollapsed()){for(let t=1;t!n.getReturnTypes()).map(n=>[n.getName(),n.getParameters().map(u=>u.getName()),!1]);e.getBlocksByType("procedures_defnoreturn",!1).forEach(n=>{!nn(n)&&Fn(n)&&t.push(n.getProcedureDef())});const i=e.getProcedureMap().getProcedures().filter(n=>!!n.getReturnTypes()).map(n=>[n.getName(),n.getParameters().map(u=>u.getName()),!0]);return e.getBlocksByType("procedures_defreturn",!1).forEach(n=>{!nn(n)&&Fn(n)&&i.push(n.getProcedureDef())}),t.sort(rc),i.sort(rc),[t,i]},rc=function(e,t){return e[0].localeCompare(t[0],void 0,{sensitivity:"base"})},oc=function(e,t){if(t.isInFlyout)return e;for(e=e||Ie.UNNAMED_KEY||"unnamed";!$p(e,t.workspace,t);){const i=e.match(/^(.*?)(\d+)$/);e=i?i[1]+(parseInt(i[2])+1):e+"2"}return e},$p=function(e,t,i){return!lc(e,t,i)},lc=function(e,t,i){for(const n of t.getAllBlocks(!1))if(n!==i&&Fn(n)&&Nt.equals(n.getProcedureDef()[0],e))return!0;i=i&&nn(i)?i==null?void 0:i.getProcedureModel():void 0;for(const n of t.getProcedureMap().getProcedures())if(n!==i&&Nt.equals(n.getName(),e))return!0;return!1},vp=function(e){var t=this.getSourceBlock();if(!t)throw new pt;e=e.trim();const i=oc(e,t);nn(t)&&!t.isInsertionMarker()&&t.getProcedureModel().setName(i);const n=this.getValue();if(n!==e&&n!==i)for(e=t.workspace.getAllBlocks(!1),t=0;tEp(i,e)||yu(i)&&Nt.equals(i.getProcedureCall(),e))},Ep=function(e,t){return nn(e)&&!e.isProcedureDef()&&e.getProcedureModel()&&Nt.equals(e.getProcedureModel().getName(),t)},bp=function(e){const t=L();var i=e.getProcedureDef()[0];const n=e.mutationToDom(!0);e=hc(i,e.workspace);for(let E=0,G;G=e[E];E++){i=(i=G.mutationToDom())&&Ct(i),G.domToMutation&&G.domToMutation(n);var u=G.mutationToDom();u=u&&Ct(u),i!==u&&(T(!1),O(new(le($t))(G,"mutation",null,i,u)),T(t))}},yp=function(e,t){for(const i of t.getAllBlocks(!1))if(nn(i)&&i.isProcedureDef()&&Nt.equals(i.getProcedureModel().getName(),e)||Fn(i)&&Nt.equals(i.getProcedureDef()[0],e))return i;return null},uc=function(e){return e.isDynamic},tr=function(){return vf},wp=function(){p("Blockly.blockRendering.debug.stopDebugger()","version 8","version 10","the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)"),vf=!1},Zn=function(e,t){m(pe.RENDERER,e,t)},Sp=function(e){P(pe.RENDERER,e)},Ip=function(){p("Blockly.blockRendering.stopDebugger()","September 2021","September 2022","the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)"),wp()},dc=function(e,t,i){return e=new(a(pe.RENDERER,e))(e),e.init(t,i),e},pc=function(e){Gn(e.getTargetWorkspace(),void 0,"String")},gc=function(e){Gn(e.getTargetWorkspace(),void 0,"Number")},fc=function(e){Gn(e.getTargetWorkspace(),void 0,"Colour")},ko=function(e){let t=[],i=document.createElement("button");return i.setAttribute("text",Ie.NEW_STRING_VARIABLE),i.setAttribute("callbackKey","CREATE_VARIABLE_STRING"),t.push(i),i=document.createElement("button"),i.setAttribute("text",Ie.NEW_NUMBER_VARIABLE),i.setAttribute("callbackKey","CREATE_VARIABLE_NUMBER"),t.push(i),i=document.createElement("button"),i.setAttribute("text",Ie.NEW_COLOUR_VARIABLE),i.setAttribute("callbackKey","CREATE_VARIABLE_COLOUR"),t.push(i),e.registerButtonCallback("CREATE_VARIABLE_STRING",pc),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",gc),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",fc),e=mc(e),t=t.concat(e)},mc=function(e){e=e.getAllVariables();const t=[];if(0$c(i))),t},$c=function(e){const t={id:e.getId(),name:e.getName()};return e.getTypes().length&&(t.types=e.getTypes()),t},vc=function(e,t,i,n){if(e=new e(n,i.name,i.id).setReturnTypes(i.returnTypes),!i.parameters)return e;for(const[u,E]of i.parameters.entries())e.insertParameter(Tc(t,E,n),u);return e},Tc=function(e,t,i){return e=new e(i,t.name,t.id),t.types&&e.setTypes(t.types),e},Dp=function(e){const t=Object.create(null),i=o(pe.SERIALIZER,!0);for(const n in i){let u;const E=(u=i[n])==null?void 0:u.save(e);E&&(t[n]=E)}return t},xp=function(e,t,{recordUndo:i=!1}={}){var n=o(pe.SERIALIZER,!0);if(n){n=Object.entries(n).sort((E,G)=>G[1].priority-E[1].priority);var u=L();T(i),(i=Y())||z(!0),He(),t instanceof _i&&t.setResizesEnabled(!1);for(const[,E]of n.reverse()){let G;(G=E)==null||G.clear(t)}for(let[E,G]of n.reverse())if(e[E]){let X;(X=G)==null||X.load(e[E],t)}t instanceof _i&&t.setResizesEnabled(!0),Qe(),O(new(le(is))(t)),z(i),T(u)}},Ec=function(){Je.registry.register({name:Di.ESCAPE,preconditionFn(e){return!e.options.readOnly},callback(e){return e.hideChaff(),!0},keyCodes:[Me.ESC]})},bc=function(){Je.registry.register({name:Di.DELETE,preconditionFn(e){const t=k();return!e.options.readOnly&&t!=null&&t.isDeletable()},callback(e,t){return t.preventDefault(),Li.inProgress()?!1:(k().checkAndDelete(),!0)},keyCodes:[Me.DELETE,Me.BACKSPACE]})},yc=function(){const e=Je.registry.createSerializedKey(Me.C,[Me.CTRL]),t=Je.registry.createSerializedKey(Me.C,[Me.ALT]),i=Je.registry.createSerializedKey(Me.C,[Me.META]);Je.registry.register({name:Di.COPY,preconditionFn(n){const u=k();return!n.options.readOnly&&!Li.inProgress()&&u!=null&&u.isDeletable()&&u.isMovable()},callback(n,u){return u.preventDefault(),n.hideChaff(),jn(k()),!0},keyCodes:[e,t,i]})},wc=function(){const e=Je.registry.createSerializedKey(Me.X,[Me.CTRL]),t=Je.registry.createSerializedKey(Me.X,[Me.ALT]),i=Je.registry.createSerializedKey(Me.X,[Me.META]);Je.registry.register({name:Di.CUT,preconditionFn(n){const u=k();return!n.options.readOnly&&!Li.inProgress()&&u!=null&&u instanceof ii&&u.isDeletable()&&u.isMovable()&&!u.workspace.isFlyout},callback(){const n=k();return n?(jn(n),n.checkAndDelete(),!0):!1},keyCodes:[e,t,i]})},Sc=function(){const e=Je.registry.createSerializedKey(Me.V,[Me.CTRL]),t=Je.registry.createSerializedKey(Me.V,[Me.ALT]),i=Je.registry.createSerializedKey(Me.V,[Me.META]);Je.registry.register({name:Di.PASTE,preconditionFn(n){return!n.options.readOnly&&!Li.inProgress()},callback(){return!!wo()},keyCodes:[e,t,i]})},Ic=function(){const e=Je.registry.createSerializedKey(Me.Z,[Me.CTRL]),t=Je.registry.createSerializedKey(Me.Z,[Me.ALT]),i=Je.registry.createSerializedKey(Me.Z,[Me.META]);Je.registry.register({name:Di.UNDO,preconditionFn(n){return!n.options.readOnly&&!Li.inProgress()},callback(n){return n.hideChaff(),n.undo(!1),!0},keyCodes:[e,t,i]})},Rc=function(){const e=Je.registry.createSerializedKey(Me.Z,[Me.SHIFT,Me.CTRL]),t=Je.registry.createSerializedKey(Me.Z,[Me.SHIFT,Me.ALT]),i=Je.registry.createSerializedKey(Me.Z,[Me.SHIFT,Me.META]),n=Je.registry.createSerializedKey(Me.Y,[Me.CTRL]);Je.registry.register({name:Di.REDO,preconditionFn(u){return!Li.inProgress()&&!u.options.readOnly},callback(u){return u.hideChaff(),u.undo(!0),!0},keyCodes:[e,t,i,n]})},Cc=function(){Ec(),bc(),yc(),wc(),Sc(),Ic(),Rc()},Bp=function(e){return e.isSelectable()},Pp=function(e){return p("Blockly.utils.getRelativeXY","December 2021","December 2022","Blockly.utils.svgMath.getRelativeXY"),ei(e)},Fp=function(e){return p("Blockly.utils.getInjectionDivXY_","December 2021","December 2022","Blockly.utils.svgMath.getInjectionDivXY"),Ps(e)},Gp=function(e){return p("Blockly.utils.tokenizeInterpolation","December 2021","December 2022","Blockly.utils.parsing.tokenizeInterpolation"),po(e)},Up=function(e){return p("Blockly.utils.replaceMessageReferences","December 2021","December 2022","Blockly.utils.parsing.replaceMessageReferences"),rt(e)},Hp=function(e){return p("Blockly.utils.checkMessageReferences","December 2021","December 2022","Blockly.utils.parsing.checkMessageReferences"),zs(e)},Vp=function(){return p("Blockly.utils.is3dSupported","December 2021","December 2022","Blockly.utils.svgMath.is3dSupported"),xl()},Wp=function(){return p("Blockly.utils.getViewportBBox","December 2021","December 2022","Blockly.utils.svgMath.getViewportBBox"),qr()},zp=function(e,t){return p("Blockly.utils.arrayRemove","December 2021","December 2022","Blockly.array.removeElem"),At(e,t)},Xp=function(){return p("Blockly.utils.getDocumentScroll","December 2021","December 2022","Blockly.utils.svgMath.getDocumentScroll"),eo()},Yp=function(e,t){return p("Blockly.utils.getBlockTypeCounts","December 2021","December 2022","Blockly.common.getBlockTypeCounts"),N(e,t)},Kp=function(e,t){return p("Blockly.utils.screenToWsCoordinates","December 2021","December 2022","Blockly.utils.svgMath.screenToWsCoordinates"),Bl(e,t)},jp=function(e){return p("Blockly.utils.parseBlockColour","December 2021","December 2022","Blockly.utils.parsing.parseBlockColour"),vn(e)},Jp=function(e){p("Blockly.utils.runAfterPageLoad","December 2021","December 2022"),Ks(e)},Zp=function(e){_().hideChaff(e)},Qp=function(e){p("Blockly.resizeSvgContents","December 2021","December 2022","Blockly.WorkspaceSvg.resizeSvgContents"),Rp(e)},qp=function(e){p("Blockly.copy","December 2021","December 2022","Blockly.clipboard.copy"),jn(e)},eg=function(){return p("Blockly.paste","December 2021","December 2022","Blockly.clipboard.paste"),!!wo()},tg=function(e){p("Blockly.duplicate","December 2021","December 2022","Blockly.clipboard.duplicate"),Js(e)},ig=function(e){return p("Blockly.isNumber","December 2021","December 2022","Blockly.utils.string.isNumber"),aa(e)},ng=function(e){return p("Blockly.hueToHex","December 2021","December 2022","Blockly.utils.colour.hueToHex"),ho(e)},sg=function(e,t,i,n){return p("Blockly.bindEvent_","December 2021","December 2022","Blockly.browserEvents.bind"),kt(e,t,i,n)},rg=function(e){return p("Blockly.unbindEvent_","December 2021","December 2022","Blockly.browserEvents.unbind"),je(e)},og=function(e,t,i,n,u,E){return p("Blockly.bindEventWithChecks_","December 2021","December 2022","Blockly.browserEvents.conditionalBind"),ve(e,t,i,n,u)},ye=ye||{},ye.scope={},ye.ASSUME_ES5=!1,ye.ASSUME_NO_NATIVE_MAP=!1,ye.ASSUME_NO_NATIVE_SET=!1,ye.SIMPLE_FROUND_POLYFILL=!1,ye.ISOLATE_POLYFILLS=!1,ye.FORCE_POLYFILL_PROMISE=!1,ye.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,ye.defineProperty=ye.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(e,t,i){return e==Array.prototype||e==Object.prototype||(e[t]=i.value),e},ye.getGlobal=function(e){e=[typeof globalThis=="object"&&globalThis,e,typeof window=="object"&&window,typeof self=="object"&&self,typeof si=="object"&&si];for(var t=0;t>>0,ye.propertyToPolyfillSymbol[u]=ye.IS_SYMBOL_NATIVE?ye.global.Symbol(u):ye.POLYFILL_PREFIX+i+"$"+u),ye.defineProperty(n,ye.propertyToPolyfillSymbol[u],{configurable:!0,writable:!0,value:t})))},ye.polyfill("globalThis",function(e){return e||ye.global},"es_2020","es3"),ye.polyfill("Object.getOwnPropertyDescriptors",function(e){return e||function(t){for(var i={},n=Reflect.ownKeys(t),u=0;u{const e=cg.length,t=[];for(let i=0;20>i;i++)t[i]=cg.charAt(Math.random()*e);return t.join("")}},Gm=0,No={};No.TEST_ONLY=hg,No.genUid=A,No.getNextUniqueId=F;var ug="",ir=!0,Oc=0,wt="create",Ri="delete",$t="change",Ot="move",bn="var_create",qn="var_delete",nr="var_rename",sr="ui",es="drag",rn="selected",on="click",rr="marker_move",Gi="bubble_open",or="trashcan_open",lr="toolbox_item_select",ar="theme_change",yn="viewport_change",wn="comment_create",ts="comment_delete",cr="comment_change",Ui="comment_move",is="finished_loading",Lc=[wt,Ot,wn,Ui],ns=[],Mc={FIRE_QUEUE:ns,fireNow:V,fireInternal:H,setGroupInternal:oe},Oe={};Oe.BLOCK_CHANGE=$t,Oe.BLOCK_CREATE=wt,Oe.BLOCK_DELETE=Ri,Oe.BLOCK_DRAG=es,Oe.BLOCK_MOVE=Ot,Oe.BUBBLE_OPEN=Gi,Oe.BUMP_EVENTS=Lc,Oe.CHANGE=$t,Oe.CLICK=on,Oe.COMMENT_CHANGE=cr,Oe.COMMENT_CREATE=wn,Oe.COMMENT_DELETE=ts,Oe.COMMENT_MOVE=Ui,Oe.CREATE=wt,Oe.DELETE=Ri,Oe.FINISHED_LOADING=is,Oe.MARKER_MOVE=rr,Oe.MOVE=Ot,Oe.SELECTED=rn,Oe.TEST_ONLY=Mc,Oe.THEME_CHANGE=ar,Oe.TOOLBOX_ITEM_SELECT=lr,Oe.TRASHCAN_OPEN=or,Oe.UI=sr,Oe.VAR_CREATE=bn,Oe.VAR_DELETE=qn,Oe.VAR_RENAME=nr,Oe.VIEWPORT_CHANGE=yn,Oe.clearPendingUndo=K,Oe.disable=Q,Oe.disableOrphans=Re,Oe.enable=ie,Oe.filter=W,Oe.fire=O,Oe.fromJson=de,Oe.get=le,Oe.getDescendantIds=he,Oe.getGroup=Y,Oe.getRecordUndo=L,Oe.isEnabled=J,Oe.setGroup=z,Oe.setRecordUndo=T;var Ae;(function(e){e[e.VALUE=1]="VALUE",e[e.STATEMENT=3]="STATEMENT",e[e.DUMMY=5]="DUMMY"})(Ae||(Ae={})),r.module$build$src$core$input_types={},r.module$build$src$core$input_types.inputTypes=Ae;var Tt=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}},Sn,Do,xo,Nc;({document:Sn,DOMParser:Do,XMLSerializer:xo}=globalThis),Nc="https://developers.google.com/blockly/xml",r.module$build$src$core$utils$xml={},r.module$build$src$core$utils$xml.NAME_SPACE=Nc,r.module$build$src$core$utils$xml.createElement=r.createElement$$module$build$src$core$utils$xml,r.module$build$src$core$utils$xml.createTextNode=Ue,r.module$build$src$core$utils$xml.domToText=Ct,r.module$build$src$core$utils$xml.getDocument=vt,r.module$build$src$core$utils$xml.injectDependencies=Ke,r.module$build$src$core$utils$xml.setDocument=nt,r.module$build$src$core$utils$xml.textToDom=De,r.module$build$src$core$utils$xml.textToDomDocument=Pt;var ss="http://www.w3.org/2000/svg",hi="http://www.w3.org/1999/xhtml",Ht="http://www.w3.org/1999/xlink",Ci;(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"})(Ci||(Ci={}));var ui=null,Dc=0,Bo=null,ft={};ft.HTML_NS=hi,ft.NodeType=Ci,ft.SVG_NS=ss,ft.XLINK_NS=Ht,ft.addClass=Te,ft.containsNode=Ne,ft.createSvgElement=ee,ft.getFastTextWidth=M,ft.getFastTextWidthWithSizeString=U,ft.getTextWidth=Ve,ft.hasClass=ae,ft.insertAfter=be,ft.measureFontMetrics=j,ft.removeClass=xe,ft.removeClasses=Ti,ft.removeNode=ue,ft.setCssTransform=Be,ft.startTextWidthCache=He,ft.stopTextWidthCache=Qe;var dg=function(e,t){window.alert(e),t&&t()},pg=function(e,t){t(window.confirm(e))},gg=function(e,t,i){i(window.prompt(e,t))},fg={confirmInternal:gn},Vt={};Vt.TEST_ONLY=fg,Vt.alert=ne,Vt.confirm=Fe,Vt.prompt=Xr,Vt.setAlert=se,Vt.setConfirm=Eu,Vt.setPrompt=bu;var Ie,xc;Ie=Object.create(null),xc=function(e){Object.keys(e).forEach(function(t){Ie[t]=e[t]})},r.module$build$src$core$msg={},r.module$build$src$core$msg.Msg=Ie,r.module$build$src$core$msg.setLocale=xc;var rs=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=Y(),this.recordUndo=L()}toJson(){return{type:this.type,group:this.group}}fromJson(e){p("Blockly.Events.Abstract.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),this.isBlank=!1,this.group=e.group||""}static fromJson(e,t,i){return i.isBlank=!1,i.group=e.group||"",i.workspaceId=t.id,i}isNull(){return!1}run(e){}getEventWorkspace_(){let e;if(this.workspaceId&&(e=l(this.workspaceId)),!e)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return e}},hr=class extends rs{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){p("Blockly.Events.VarBase.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.varId=e.varId}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new hr),t.varId=e.varId,t}},Bc=class extends hr{constructor(e){super(e),this.type=bn,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){p("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,i){return t=super.fromJson(e,t,i??new Bc),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)}};m(pe.EVENT,bn,Bc);var ur=class{constructor(e,t,i,n){this.workspace=e,this.name=t,this.type=i||"",this.id_=n||A()}getId(){return this.id_}static compareByName(e,t){return e.name.localeCompare(t.name,void 0,{sensitivity:"base"})}},Po,Fo,Pc;Po="VARIABLE",Fo="ijkmnopqrstuvwxyzabcdefgh",Pc={generateUniqueNameInternal:Su},r.module$build$src$core$variables={},r.module$build$src$core$variables.CATEGORY_NAME=Po,r.module$build$src$core$variables.TEST_ONLY=Pc,r.module$build$src$core$variables.VAR_LETTER_OPTIONS=Fo,r.module$build$src$core$variables.allDeveloperVariables=wu,r.module$build$src$core$variables.allUsedVarModels=Yr,r.module$build$src$core$variables.createVariableButtonHandler=Gn,r.module$build$src$core$variables.flyoutCategory=Kr,r.module$build$src$core$variables.flyoutCategoryBlocks=wl,r.module$build$src$core$variables.generateUniqueName=Sl,r.module$build$src$core$variables.generateUniqueNameFromOptions=jr,r.module$build$src$core$variables.generateVariableFieldDom=fn,r.module$build$src$core$variables.getAddedVariables=Zr,r.module$build$src$core$variables.getOrCreateVariablePackage=Ls,r.module$build$src$core$variables.getVariable=Ms,r.module$build$src$core$variables.nameUsedWithAnyType=Rl,r.module$build$src$core$variables.nameUsedWithConflictingParam=Cl,r.module$build$src$core$variables.promptName=Jr,r.module$build$src$core$variables.renameVariable=Il;var ge=class{constructor(e,t){this.x=e,this.y=t}clone(){return new ge(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 i=e.x-t.x;return e=e.y-t.y,Math.sqrt(i*i+e*e)}static magnitude(e){return Math.sqrt(e.x*e.x+e.y*e.y)}static difference(e,t){return new ge(e.x-t.x,e.y-t.y)}static sum(e,t){return new ge(e.x+t.x,e.y+t.y)}},ki=class{constructor(e,t,i,n,u){this.workspace=e,this.editable_=this.movable_=this.deletable_=!0,this.disposed_=!1,this.isComment=!0,this.id=u&&!e.getCommentById(u)?u:A(),e.addTopComment(this),this.xy_=new ge(0,0),this.height_=i,this.width_=n,this.RTL=e.RTL,this.content_=t,ki.fireCreateEvent(this)}dispose(){this.disposed_||(J()&&O(new(le(ts))(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 ge(this.xy_.x,this.xy_.y)}moveBy(e,t){const i=new(le(Ui))(this);this.xy_.translate(e,t),i.recordNew(),O(i)}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&&(O(new(le(cr))(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=r.createElement$$module$build$src$core$utils$xml("comment");return e||(t.id=this.id),t.textContent=this.getContent(),t}static fireCreateEvent(e){if(J()){const t=Y();t||z(!0);try{O(new(le(wn))(e))}finally{z(t)}}}static fromXml(e,t){var i=ki.parseAttributes(e);return t=new ki(t,i.content,i.h,i.w,i.id),i=e.getAttribute("x"),e=e.getAttribute("y"),i=i?parseInt(i,10):NaN,e=e?parseInt(e,10):NaN,isNaN(i)||isNaN(e)||t.moveBy(i,e),ki.fireCreateEvent(t),t}static parseAttributes(e){const t=e.getAttribute("h"),i=e.getAttribute("w"),n=e.getAttribute("x"),u=e.getAttribute("y"),E=e.getAttribute("id");if(!E)throw Error("No ID present in XML comment definition.");let G;return{id:E,h:t?parseInt(t):100,w:i?parseInt(i):100,x:n?parseInt(n):NaN,y:u?parseInt(u):NaN,content:(G=e.textContent)!=null?G:""}}},di=class extends rs{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=typeof e>"u",this.workspaceId=e||""}},Fc=class extends di{constructor(e,t,i){super(i),this.type=rn,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){p("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,i){return t=super.fromJson(e,t,i??new Fc),t.oldElementId=e.oldElementId,t.newElementId=e.newElementId,t}};m(pe.EVENT,rn,Fc);var Um=750,mg="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Go=null,In={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Uo=0,Yt={};Yt.TOUCH_ENABLED=mg,Yt.TOUCH_MAP=In,Yt.checkTouchIdentifier=Al,Yt.clearTouchIdentifier=bi,Yt.getTouchIdentifierFromEvent=Un,Yt.isMouseOrTouchEvent=Ou,Yt.isTouchEvent=Lu,Yt.longStart=kl,Yt.longStop=Ei,Yt.setClientFromTouch=Au,Yt.shouldHandleEvent=Ns,Yt.splitEventByTouches=Mu;var Gc,_g,$g,vg,Ho,Vo,Uc,Tg,Eg,bg;(function(e){function t(n){return i.indexOf(n.toUpperCase())!==-1}Gc=e;const i=Gc.toUpperCase();_g=t("JavaFX"),$g=t("WebKit"),vg=t("Gecko")&&!$g,Ho=t("Android"),e=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Vo=t("iPad")||t("Macintosh")&&0$ in T?L_(T,$,{enumerable:!0,configurable:!0,writable:!0,value:s}):T[$]=s;var qe=(T,$,s)=>(M_(T,typeof $!="symbol"?$+"":$,s),s);(function(){const $=document.createElement("link").relList;if($&&$.supports&&$.supports("modulepreload"))return;for(const m of document.querySelectorAll('link[rel="modulepreload"]'))p(m);new MutationObserver(m=>{for(const B of m)if(B.type==="childList")for(const P of B.addedNodes)P.tagName==="LINK"&&P.rel==="modulepreload"&&p(P)}).observe(document,{childList:!0,subtree:!0});function s(m){const B={};return m.integrity&&(B.integrity=m.integrity),m.referrerPolicy&&(B.referrerPolicy=m.referrerPolicy),m.crossOrigin==="use-credentials"?B.credentials="include":m.crossOrigin==="anonymous"?B.credentials="omit":B.credentials="same-origin",B}function p(m){if(m.ep)return;m.ep=!0;const B=s(m);fetch(m.href,B)}})();var si=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function vm(T){return T&&T.__esModule&&Object.prototype.hasOwnProperty.call(T,"default")?T.default:T}var Tm={exports:{}},au={exports:{}},cu={exports:{}},hu={exports:{}},uu={exports:{}},lm;function $u(){return lm||(lm=1,function(T,$){(function(s,p){T.exports=p()})(si,function(){var s={},p,m,B,P,C,f,a,r,o,c,l,h,d,g,_,v,M,y,I,w,x,N,D,R,S,F,A,E,O,k,H,V,W,K,Q,ie,J,Y,z,oe,he,de,fe,le,Re,je,vt,nt,Ue,De,Pt,Ct,ee,Te,Ti,xe,ae,ue,be,Ne,Be,Ve,Qe,We,L,U,j,ne,se,Fe,fn,Tu,Xr,Eu,yl,Gn,bu,Yr,yu,Kr,wl,Sl,wu,jr,Un,Il,Jr,Su,Rl,Cl,Iu,Ru,mn,Ls,Ms,Cu,Zr,Al,Ei,bi,Ns,Hn,kl,Au,ku,Ou,Lu,ve,At,Je,Ds,Bi,_n,xs,ei,Ol,Bs,Mu,Ll,yi,Nu,Zi,Ml,Nl,Qr,Dl,ti,Ps,xl,qr,eo,Bl,Du,Pl,Fs,xu,Bu,Qi,Fl,wi,Pu,Fu,Gu,Vn,Uu,$n,Gl,Hu,Vu,Wu,zu,Xu,Ul,Yu,Ku,to,ju,Ju,Hl,io,Zu,Si,Qu,qu,ed,td,id,nd,sd,Vl,qi,no,Wl,rd,od,ld,ad,cd,hd,ud,dd,zl,pd,gd,fd,md,Wn,Xl,zn,Yl,Kl,jl,Xn,so,ro,_d,Gs,Jl,Zl,Ql,ql,ea,ta,$d,Us,ia,Yn,oo,oi,na,vd,Td,Hs,sa,ra,oa,Ed,lo,la,bd,aa,yd,wd,Sd,Id,Kn,ca,ha,Vs,ua,Rd,Cd,da,pa,en,ga,fa,Ad,kd,Od,Ld,ma,Md,_a,Nd,tn,Ws,ao,co,vn,ho,uo,po,rt,zs,Tn,En,Dd,$a,go,li,va,fo,Ta,Ea,xd,Bd,Yt,Pd,mo,Fd,ai,st,Gd,Ud,ba,Hd,Vd,Pi,Wd,Xs,zd,Ys,_o,Xd,$o,Yd,vo,ya,wa,Kd,jd,Sa,To,Jd,Zd,Qd,Ia,Eo,Ra,bo,qd,Ks,ep,tp,kt,Ca,Aa,ka,Oa,La,Ma,jn,js,Na,ip,yo,np,Jn,sp,wo,Js,rp,op,Da,Zs,lp,ap,cp,hp,Qs,xa,up,Ba,Pa,dp,qs,Ee,Ft,yt,tt,Ii,Zn,_e,ht,pp,Fa,gp,Ga,Ua,Ha,Va,Wa,za,Xa,Ya,Ka,ja,So,er,Ja,fp,Za,Qa,qa,ec,tc,ic,nc,mp,sc,nn,Io,Ro,rc,oc,_p,lc,$p,Co,ac,cc,vp,hc,Tp,Ep,bp,uc,tr,yp,Qn,wp,Sp,dc,pc,gc,fc,Ao,mc,ko,Oo,Lo,Ip,Rp,Cp,Ap,kp,Op,Lp,Mp,_c,$c,vc,Tc,Np,Dp,Ec,bc,yc,wc,Sc,Ic,Rc,Cc,xp,Bp,Pp,Fp,Gp,Up,Hp,Vp,Wp,zp,Xp,Yp,Kp,jp,Jp,Zp,Qp,qp,eg,tg,ig,ng,sg,rg,ye;p=function(e,t,i,n){e=e+" was deprecated in "+t+" and will be deleted in "+i+".",n&&(e+=` +Use `+n+" instead."),console.warn(e)},m=function(e,t,i,n){if(!(e instanceof pe)&&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 u=t.toLowerCase();if(!i)throw Error("Can not register a null value");let b=sn[e],G=Mo[e];if(b||(b=sn[e]=Object.create(null),G=Mo[e]=Object.create(null)),B(e,i),!n&&b[u])throw Error('Name "'+u+'" with type "'+e+'" already registered.');b[u]=i,G[u]=t},B=function(e,t){switch(e){case String(pe.FIELD):if(typeof t.fromJson!="function")throw Error('Type "'+e+'" must have a fromJson function')}},P=function(e,t){e=`${e}`.toLowerCase(),t=t.toLowerCase();const i=sn[e];i&&i[t]?(delete sn[e][t],delete Mo[e][t]):console.warn("Unable to unregister ["+t+"]["+e+"] from the registry.")},C=function(e,t,i){e=`${e}`.toLowerCase(),t=t.toLowerCase();const n=sn[e];if(!n||!n[t]){if(t="Unable to find ["+t+"]["+e+"] in the registry.",i)throw Error(t+" You must require or register a "+e+" plugin.");return console.warn(t),null}return n[t]},f=function(e,t){return e=`${e}`.toLowerCase(),t=t.toLowerCase(),(e=sn[e])?!!e[t]:!1},a=function(e,t,i){return C(e,t,i)},r=function(e,t,i){return C(e,t,i)},o=function(e,t,i){e=`${e}`.toLowerCase();var n=sn[e];if(!n){if(n=`Unable to find [${e}] in the registry.`,i)throw Error(`${n} You must require or register a ${e} plugin.`);return console.warn(n),null}if(!t)return n;e=Mo[e],i=Object.create(null);for(const u of Object.keys(n))i[e[u]]=n[u];return i},c=function(e,t,i){return t=t.plugins[String(e)]||Fi,typeof t=="function"?t:a(e,t,i)},l=function(e){return qn[e]||null},h=function(){const e=[];for(const t in qn)e.push(qn[t]);return e},d=function(e){qn[e.id]=e},g=function(e){delete qn[e.id]},_=function(){return og},v=function(e){og=e},M=function(){return Ac},y=function(e){Ac=e},I=function(){return lg},w=function(e){lg=e},x=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;const t=e.getParentSvg(),i=e.getCachedParentSvgSize();var n=t.parentElement;if(n instanceof HTMLElement){var u=n.offsetWidth;n=n.offsetHeight,i.width!==u&&(t.setAttribute("width",u+"px"),e.setCachedParentSvgSize(u,null)),i.height!==n&&(t.setAttribute("height",n+"px"),e.setCachedParentSvgSize(null,n)),e.resize()}},N=function(e,t){const i=Object.create(null),n=e.getDescendants(!0);t&&(e=e.getNextBlock())&&(e=n.indexOf(e),n.splice(e,n.length-e));for(let u=0,b;b=n[u];u++)i[b.type]?i[b.type]++:i[b.type]=1;return i},D=function(e){return function(){this.jsonInit(e)}},R=function(e){kc.defineBlocksWithJsonArrayInternal(e)},S=function(e){s.defineBlocks$$module$build$src$core$common(s.createBlockDefinitionsFromJsonArray$$module$build$src$core$common(e))},s.createBlockDefinitionsFromJsonArray$$module$build$src$core$common=function(e){const t={};for(let i=0;i{setTimeout(V,0)})}catch{setTimeout(V,0)}ss.push(e)}},V=function(){const e=W(ss,!0);ss.length=0;for(let t=0,i;i=e[t];t++){if(!i.workspaceId)continue;const n=l(i.workspaceId);n&&n.fireChangeListener(i)}},W=function(e,t){e=e.slice(),t||e.reverse();const i=[],n=Object.create(null);for(let G=0,X;X=e[G];G++)if(!X.isNull()){var u=[X.isUiEvent?sr:X.type,X.blockId,X.workspaceId].join(" "),b=n[u];const re=b?b.event:null;b?X.type===Ot&&b.index===G-1?(u=X,re.newParentId=u.newParentId,re.newInputName=u.newInputName,re.newCoordinate=u.newCoordinate,b.index=G):X.type===$t&&X.element===re.element&&X.name===re.name?re.newValue=X.newValue:X.type===wn?(b=X,re.viewTop=b.viewTop,re.viewLeft=b.viewLeft,re.scale=b.scale,re.oldScale=b.oldScale):(X.type!==on||re.type!==Gi)&&(n[u]={event:X,index:G},i.push(X)):(n[u]={event:X,index:G},i.push(X))}e=i.filter(function(G){return!G.isNull()}),t||e.reverse();for(let G=1,X;X=e[G];G++)X.type===$t&&X.element==="mutation"&&e.unshift(e.splice(G,1)[0]);return e},K=function(){for(let e=0,t;t=ss[e];e++)t.recordUndo=!1},Q=function(){Oc++},ie=function(){Oc--},J=function(){return Oc===0},Y=function(){return hg},z=function(e){Mc.setGroupInternal(e)},oe=function(e){hg=typeof e=="boolean"?e?A():"":e},he=function(e){const t=[];e=e.getDescendants(!1);for(let i=0,n;n=e[i];i++)t[i]=n.id;return t},de=function(e,t){var i=le(e.type);if(!i)throw Error("Unknown event type.");return fe(i)?i.fromJson(e,t):(i=new i,i.fromJson(e),i.workspaceId=t.id,i)},fe=function(e){return Object.getOwnPropertyDescriptors(e).fromJson&&typeof e.fromJson=="function"},le=function(e){const t=a(pe.EVENT,e);if(!t)throw Error(`Event type ${e} not found in registry.`);return t},Re=function(e){if((e.type===Ot||e.type===wt)&&e.workspaceId){var t=l(e.workspaceId);if(!e.blockId)throw Error("Encountered a blockEvent without a proper blockId");if(e=t.getBlockById(e.blockId)){const i=ir;try{ir=!1;const n=e.getParent();if(n&&n.isEnabled()){const u=e.getDescendants(!1);for(let b=0,G;G=u[b];b++)G.setEnabled(!0)}else if((e.outputConnection||e.previousConnection)&&!t.isDragging())do e.setEnabled(!1),e=e.getNextBlock();while(e)}finally{ir=i}}}},je=function(e){({document:In=In,DOMParser:Do=Do,XMLSerializer:xo=xo}=e)},vt=function(){return p("Blockly.utils.xml.getDocument","version 9","version 10"),In},nt=function(e){p("Blockly.utils.xml.setDocument","version 9","version 10"),In=e},s.createElement$$module$build$src$core$utils$xml=function(e){return In.createElementNS(Nc,e)},Ue=function(e){return In.createTextNode(e)},De=function(e){const t=Pt(e);if(!t||!t.documentElement||t.getElementsByTagName("parsererror").length)throw Error("textToDom was unable to parse: "+e);return t.documentElement},Pt=function(e){return new Do().parseFromString(e,"text/xml")},Ct=function(e){return new xo().serializeToString(e)},ee=function(e,t,i){e=document.createElementNS(rs,`${e}`);for(const n in t)e.setAttribute(n,`${t[n]}`);return i&&i.appendChild(e),e},Te=function(e,t){return t=t.split(" "),t.every(i=>e.classList.contains(i))?!1:(e.classList.add(...t),!0)},Ti=function(e,t){e.classList.remove(...t.split(" "))},xe=function(e,t){return t=t.split(" "),t.every(i=>!e.classList.contains(i))?!1:(e.classList.remove(...t),!0)},ae=function(e,t){return e.classList.contains(t)},ue=function(e){return e&&e.parentNode?e.parentNode.removeChild(e):null},be=function(e,t){const i=t.nextSibling;if(t=t.parentNode,!t)throw Error("Reference node has no parent.");i?t.insertBefore(e,i):t.appendChild(e)},Ne=function(e,t){return!!(e.compareDocumentPosition(t)&Ci.DOCUMENT_POSITION_CONTAINED_BY)},Be=function(e,t){e.style.transform=t,e.style["-webkit-transform"]=t},Ve=function(){Dc++,ui||(ui=Object.create(null))},Qe=function(){Dc--,Dc||(ui=null)},We=function(e){const t=e.textContent+` +`+e.className.baseVal;let i;if(ui&&(i=ui[t]))return i;try{i=e.getComputedTextLength()}catch{return 8*e.textContent.length}return ui&&(ui[t]=i),i},L=function(e,t,i,n){return U(e,t+"pt",i,n)},U=function(e,t,i,n){const u=e.textContent;e=u+` +`+e.className.baseVal;var b;return ui&&(b=ui[e])||(Bo||(b=document.createElement("canvas"),b.className="blocklyComputeCanvas",document.body.appendChild(b),Bo=b.getContext("2d")),Bo.font=i+" "+t+" "+n,b=u?Bo.measureText(u).width:0,ui&&(ui[e]=b)),b},j=function(e,t,i,n){const u=document.createElement("span");u.style.font=i+" "+t+" "+n,u.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(u),t.appendChild(e),document.body.appendChild(t),i={height:0,baseline:0};try{t.style.alignItems="baseline",i.baseline=e.offsetTop-u.offsetTop,t.style.alignItems="flex-end",i.height=e.offsetTop-u.offsetTop}finally{document.body.removeChild(t)}return i},ne=function(e,t){ug(e,t)},se=function(e){ug=e},Fe=function(e,t){gg.confirmInternal(e,t)},fn=function(e,t){dg(e,t)},Tu=function(e){dg=e},Xr=function(e,t,i){pg(e,t,i)},Eu=function(e){pg=e},yl=function(e){return e.getVariableModel!==void 0},Gn=function(e){return e.getProcedureDef!==void 0},bu=function(e){return e.getProcedureCall!==void 0&&e.renameProcedure!==void 0},Yr=function(e){e=e.getAllBlocks(!1);const t=new Set;for(let i=0;i1'),n.appendChild(i),t.push(n)),Ut.variables_get){e.sort(ur.compareByName);for(let u=0,b;b=e[u];u++)i=s.createElement$$module$build$src$core$utils$xml("block"),i.setAttribute("type","variables_get"),i.setAttribute("gap","8"),i.appendChild(mn(b)),t.push(i)}}return t},Sl=function(e){return Pc.generateUniqueNameInternal(e)},wu=function(e){return jr(Fo.charAt(0),e.getAllVariableNames())},jr=function(e,t){if(!t.length)return e;const i=Fo;let n="",u=i.indexOf(e);for(;;){let b=!1;for(let G=0;Gb.getVariableModel().name);if(n&&(i=n.some(b=>b.toLowerCase()===e),n=n.some(b=>b.toLowerCase()===t),i&&n))return u.getName()}return null},Ru=function(e,t,i){e=e.toLowerCase(),t=t.toLowerCase(),i=i.getAllBlocks(!1);for(const u of i){if(!Gn(u))continue;i=u.getProcedureDef();var n=i[1];const b=n.some(G=>G.toLowerCase()===e);if(n=n.some(G=>G.toLowerCase()===t),b&&n)return i[0]}return null},mn=function(e){const t=s.createElement$$module$build$src$core$utils$xml("field");return t.setAttribute("name","VAR"),t.setAttribute("id",e.getId()),t.setAttribute("variabletype",e.type),e=Ue(e.name),t.appendChild(e),t},Ls=function(e,t,i,n){let u=Ms(e,t,i,n);return u||(u=Cu(e,t,i,n)),u},Ms=function(e,t,i,n){const u=e.getPotentialVariableMap();let b=null;if(t&&(b=e.getVariableById(t),!b&&u&&(b=u.getVariableById(t)),b))return b;if(i){if(n===void 0)throw Error("Tried to look up a variable by name without a type");b=e.getVariable(i,n),!b&&u&&(b=u.getVariable(i,n))}return b},Cu=function(e,t,i,n){const u=e.getPotentialVariableMap();return i||(i=Sl(e.isFlyout?e.targetWorkspace:e)),u?u.createVariable(i,n,t):e.createVariable(i,n,t)},Zr=function(e,t){e=e.getAllVariables();const i=[];if(t.length!==e.length)for(let n=0;n>>/g,e),Xc="",e=document.createElement("style"),e.id="blockly-common-style",t=document.createTextNode(t),e.appendChild(t),document.head.insertBefore(e,document.head.firstChild)))},Bs=function(e){return Ig.getSizeInternal(e)},Mu=function(e){if(yi(e,"display")!=="none")return Ll(e);const t=e.style,i=t.display,n=t.visibility,u=t.position;t.visibility="hidden",t.position="absolute",t.display="inline";const b=e.offsetWidth;return e=e.offsetHeight,t.display=i,t.position=u,t.visibility=n,new Tt(b,e)},Ll=function(e){return new Tt(e.offsetWidth,e.offsetHeight)},yi=function(e,t){return e=window.getComputedStyle(e),e[t]||e.getPropertyValue(t)},Nu=function(e,t){return p("Blockly.utils.style.getCascadedStyle","version 9","version 10"),e.currentStyle?e.currentStyle[t]:""},Zi=function(e){const t=new ge(0,0);e=e.getBoundingClientRect();var i=document.documentElement;return i=new ge(window.pageXOffset||i.scrollLeft,window.pageYOffset||i.scrollTop),t.x=e.left+i.x,t.y=e.top+i.y,t},Ml=function(){const e=document.body,t=document.documentElement;return new ge(e.scrollLeft||t.scrollLeft,e.scrollTop||t.scrollTop)},Nl=function(e){const t=parseFloat(yi(e,"borderLeftWidth")),i=parseFloat(yi(e,"borderRightWidth")),n=parseFloat(yi(e,"borderTopWidth"));return e=parseFloat(yi(e,"borderBottomWidth")),new ct(n,e,t,i)},Qr=function(e,t,i){e=Dl(e,t,i),t.scrollLeft=e.x,t.scrollTop=e.y},Dl=function(e,t,i){var n=Zi(e),u=Zi(t),b=Nl(t);const G=n.x-u.x-b.left;return n=n.y-u.y-b.top,u=Ll(e),e=t.clientWidth-u.width,u=t.clientHeight-u.height,b=t.scrollLeft,t=t.scrollTop,i?(b+=G-e/2,t+=n-u/2):(b+=Math.min(G,Math.max(G-e,0)),t+=Math.min(n,Math.max(n-u,0))),new ge(b,t)},ti=function(e){const t=new ge(0,0);var i=e.x&&e.getAttribute("x");const n=e.y&&e.getAttribute("y");return i&&(t.x=parseInt(i)),n&&(t.y=parseInt(n)),(i=(i=e.getAttribute("transform"))&&i.match(Rg))&&(t.x+=Number(i[1]),i[3]&&(t.y+=Number(i[3]))),(e=e.getAttribute("style"))&&-1/g,"<$1$2>")},Pu=function(e){e=wi(e).split("<");let t="";for(let i=1;i"&&(t+=" ")}return e=e.join(` +`),e=e.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1"),e.replace(/^\n/,"")},Fu=function(e){return p("Blockly.Xml.textToDom","version 9","version 10","Use Blockly.utils.xml.textToDom instead"),De(e)},Gu=function(e,t){return t.setResizesEnabled(!1),t.clear(),e=Vn(e,t),t.setResizesEnabled(!0),e},Vn=function(e,t){let i=0;t.RTL&&(i=t.getWidth());const n=[];Ve();const u=Y();u||z(!0),t.setResizesEnabled&&t.setResizesEnabled(!1);let b=!0;try{for(let G=0,X;X=e.childNodes[G];G++){const re=X.nodeName.toLowerCase(),me=X;if(re==="block"||re==="shadow"&&!O()){const lt=$n(me,t);n.push(lt.id);let at;const zt=parseInt((at=me.getAttribute("x"))!=null?at:"10",10);let As;const ks=parseInt((As=me.getAttribute("y"))!=null?As:"10",10);isNaN(zt)||isNaN(ks)||lt.moveBy(t.RTL?i-zt:zt,ks),b=!1}else{if(re==="shadow")throw TypeError("Shadow block cannot be a top-level block.");if(re==="comment")t.rendered?St.fromXmlRendered(me,t,i):Ai.fromXml(me,t);else if(re==="variables"){if(b)Gl(me,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.");b=!1}}}}finally{z(u),Qe()}return t.setResizesEnabled&&t.setResizesEnabled(!0),k(new(le(ns))(t)),n},Uu=function(e,t){if(!t.getBlocksBoundingBox)return Vn(e,t);var i=t.getBlocksBoundingBox();if(e=Vn(e,t),i&&i.top!==i.bottom){var n=i.bottom;i=t.RTL?i.right:i.left;var u=1/0;let b=-1/0,G=1/0;for(let X=0;Xb&&(b=re.x)}for(n=n-G+10,i=t.RTL?i-b:i-u,u=0;u{G.disposed||G.setConnectionTracking(!0)},1),G},Wl=function(e,t,{parentConnection:i,isShadow:n=!1}={}){if(!e.type)throw new Ag(e);const u=t.newBlock(e.type,e.id);return u.setShadow(n),rd(u,e),od(u,e),ld(u,e),ad(i,u,e),cd(u,e),hd(u,e),ud(u,e),dd(u,e),pd(u,t.rendered),u},rd=function(e,t){let i=t.x===void 0?0:t.x;t=t.y===void 0?0:t.y;const n=e.workspace;i=n.RTL?n.getWidth()-i:i,e.moveBy(i,t)},od=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)},ld=function(e,t){t.extraState&&(e.loadExtraState?e.loadExtraState(t.extraState):e.domToMutation&&e.domToMutation(De(t.extraState)))},ad=function(e,t,i){if(e){if(e.getSourceBlock().isShadow()&&!t.isShadow())throw new Og(i);if(e.type===ke.VALUE){var n=t.outputConnection;if(!n)throw new pr("output",t,i)}else if(n=t.previousConnection,!n)throw new pr("previous",t,i);if(!e.connect(n)){const u=t.workspace.connectionChecker;throw new kg(u.getErrorMessage(u.canConnectWithReason(n,e,!1),n,e),e.type===ke.VALUE?"output connection":"previous connection",t,i)}}},cd=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 Tt(t.width,t.height)),t.pinned&&e.rendered&&!e.isInFlyout&&setTimeout(()=>e.getCommentIcon().setVisible(!0),1))},hd=function(e,t){if(t.fields){var i=Object.keys(t.fields);for(let n=0;nt&&(t=i[n].length);var u=-1/0;let b,G=1;do{n=u,b=e,e=[],u=i.length/G;let X=1;for(let re=0;ren);return b},lo=function(e,t,i){const n=[0],u=[];for(var b=0;bn&&(n=X,u=G)}return u?la(e,u,i):t},bd=function(e,t){const i=[];for(let n=0;nHg&&en()}else $r!==ii&&(clearTimeout(On),nh=e.pageX,sh=e.pageY,On=setTimeout(Ld,Vg))},pa=function(){$r=ii=null,en()},en=function(){_r&&(_r=!1,gt&&(gt.style.display="none")),On&&(clearTimeout(On),On=0)},ga=function(){en(),gs=!0},fa=function(){gs=!1},Ad=function(){gt&&ii&&(typeof Jo=="function"?Jo(gt,ii):kd())},kd=function(){var e=Kn(ii);e=oa(e,Gg),e=e.split(` +`);for(let t=0;ti+window.scrollY&&(u-=gt.offsetHeight+2*oh),e?n=Math.max(Zo-window.scrollX,n):n+gt.offsetWidth>t+window.scrollX-2*Zo&&(n=t-gt.offsetWidth-2*Zo),{x:n,y:u}},Ld=function(){if(!gs&&($r=ii,gt)){gt.textContent="",Ad();var e=ii.RTL;gt.style.direction=e?"rtl":"ltr",gt.style.display="block",_r=!0;var{x:t,y:i}=Od(e);gt.style.left=t+"px",gt.style.top=i+"px"}},ma=function(){return lh},Md=function(e){lh=e},_a=function(){return ah},Nd=function(e){ah=e},tn=function(e){e=`${e}`.toLowerCase().trim();var t=Wg[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 i=e.match(/^(?:rgb)?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);return i&&(e=Number(i[1]),t=Number(i[2]),i=Number(i[3]),0<=e&&256>e&&0<=t&&256>t&&0<=i&&256>i)?Ws(e,t,i):null},Ws=function(e,t,i){return t=e<<16|t<<8|i,16>e?"#"+(16777216|t).toString(16).substr(1):"#"+t.toString(16)},ao=function(e){return e=tn(e),e?(e=parseInt(e.substr(1),16),[e>>16,e>>8&255,e&255]):[0,0,0]},co=function(e,t,i){let n=0,u=0,b=0;if(t===0)b=u=n=i;else{const G=Math.floor(e/60),X=e/60-G;e=i*(1-t);const re=i*(1-t*X);switch(t=i*(1-t*(1-X)),G){case 1:n=re,u=i,b=e;break;case 2:n=e,u=i,b=t;break;case 3:n=e,u=re,b=i;break;case 4:n=t,u=e,b=i;break;case 5:n=i,u=e,b=re;break;case 6:case 0:n=i,u=t,b=e}}return Ws(Math.floor(n),Math.floor(u),Math.floor(b))},vn=function(e,t,i){return e=tn(e),!e||(t=tn(t),!t)?null:(e=ao(e),t=ao(t),Ws(Math.round(t[0]+i*(e[0]-t[0])),Math.round(t[1]+i*(e[1]-t[1])),Math.round(t[2]+i*(e[2]-t[2]))))},ho=function(e){return co(e,lh,255*ah)},uo=function(e,t){const i=[];var n=e.split("");n.push("");var u=0;e=[];let b=null;for(let re=0;re=G?(u=2,b=G,(G=e.join(""))&&i.push(G),e.length=0):G==="{"?u=3:(e.push("%",G),u=0);else if(u===2)if("0"<=G&&"9">=G)b+=G;else{var X=void 0;i.push(parseInt((X=b)!=null?X:"",10)),re--,u=0}else u===3&&(G===""?(e.splice(0,0,"%{"),re--,u=0):G!=="}"?e.push(G):(u=e.join(""),/[A-Z]\w*/i.test(u)?(G=u.toUpperCase(),(G=G.startsWith("BKY_")?G.substring(4):null)&&G in Ie?(u=Ie[G],typeof u=="string"?Array.prototype.push.apply(i,uo(u,t)):t?i.push(`${u}`):i.push(u)):i.push("%{"+u+"}")):i.push("%{"+u+"}"),u=e.length=0))}for((t=e.join(""))&&i.push(t),X=[],e.length=0,n=0;n=i)return{hue:i,hex:co(i,ma(),255*_a())};if(i=tn(t))return{hue:null,hex:i};throw i='Invalid colour: "'+t+'"',e!==t&&(i+=' (from "'+e+'")'),Error(i)},En=function(){return pi},Dd=function(e){pi=e},$a=function(){pi||(pi=document.createElement("div"),pi.className="blocklyWidgetDiv",(I()||document.body).appendChild(pi))},go=function(e,t,i){li(),Qo=e,qo=i,(e=pi)&&(e.style.direction=t?"rtl":"ltr",e.style.display="block",t=_(),fs=t.getRenderer().getClassName(),ms=t.getTheme().getClassName(),fs&&Te(e,fs),ms&&Te(e,ms))},li=function(){if(va()){Qo=null;var e=pi;e&&(e.style.display="none",e.style.left="",e.style.top="",qo&&qo(),qo=null,e.textContent="",fs&&(xe(e,fs),fs=""),ms&&(xe(e,ms),ms=""),_().markFocused())}},va=function(){return!!Qo},fo=function(e){Qo===e&&li()},Ta=function(e,t,i){pi.style.left=e+"px",pi.style.top=t+"px",pi.style.height=i+"px"},Ea=function(e,t,i,n){const u=Bd(e,t,i);e=xd(e,t,i,n),0>u?Ta(e,0,i.height+u):Ta(e,u,i.height)},xd=function(e,t,i,n){return n?Math.min(Math.max(t.right-i.width,e.left),e.right-i.width):Math.max(Math.min(t.left,e.right-i.width),e.left)},Bd=function(e,t,i){return t.bottom+i.height>=e.bottom?t.top-i.height:t.bottom},Yt=function(e,t){m(pe.FIELD,e,t)},Pd=function(e){P(pe.FIELD,e)},mo=function(e){return ch.fromJsonInternal(e)},Fd=function(e){const t=r(pe.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},ai=function(e,t){e.setAttribute(Xm,t)},st=function(e,t,i){Array.isArray(i)&&(i=i.join(" ")),e.setAttribute(zm+t,`${i}`)},Gd=function(e){let t=!1;const i=e.map(([G,X])=>typeof G=="string"?[rt(G),X]:(t=!0,[G.alt!==null?Object.assign({},G,{alt:rt(G.alt)}):Object.assign({},G),X]));if(t||2>e.length)return{options:i};var n=i.map(([G])=>G),u=Hs(n);e=sa(n,u);const b=ra(n,u);return!e&&!b||u<=e+b?{options:i}:(u=e?n[0].substring(0,e-1):void 0,n=b?n[0].substr(1-b):void 0,{options:Ud(i,e,b),prefix:u,suffix:n})},Ud=function(e,t,i){return e.map(([n,u])=>[n.substring(t,n.length-i),u])},ba=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 i=0;i document.")}else e instanceof Element&&(t=e);return t},s.register$$module$build$src$core$extensions=function(e,t){if(typeof e!="string"||e.trim()==="")throw Error('Error: Invalid extension name "'+e+'"');if(_s[e])throw Error('Error: Extension "'+e+'" is already registered.');if(typeof t!="function")throw Error('Error: Extension "'+e+'" must be a function');_s[e]=t},Kd=function(e,t){if(!t||typeof t!="object")throw Error('Error: Mixin "'+e+'" must be a object');s.register$$module$build$src$core$extensions(e,function(){this.mixin(t)})},s.registerMutator$$module$build$src$core$extensions=function(e,t,i,n){const u='Error when registering mutator "'+e+'": ';Ra(u,t);const b=Ia(t,u);if(i&&typeof i!="function")throw Error(u+'Extension "'+e+'" is not a function');s.register$$module$build$src$core$extensions(e,function(){b&&this.setMutator(new s.Mutator$$module$build$src$core$mutator(n||[],this)),this.mixin(t),i&&i.apply(this)})},jd=function(e){Sa(e)?delete _s[e]:console.warn('No extension mapping for name "'+e+'" found to unregister')},Sa=function(e){return!!_s[e]},To=function(e,t,i){const n=_s[e];if(typeof n!="function")throw Error('Error: Extension "'+e+'" not found.');let u;if(i?Jd(e,t):u=bo(t),n.apply(t),i)Ra('Error after applying mutator "'+e+'": ',t);else if(!qd(u,t))throw Error('Error when applying extension "'+e+'": mutation properties changed when applying a non-mutator extension.')},Jd=function(e,t){if(bo(t).length)throw Error('Error: tried to apply mutation "'+e+'" to a block that already has mutator functions. Block id: '+t.id)},Zd=function(e,t){return Eo(e.mutationToDom,e.domToMutation,t+" mutationToDom/domToMutation")},Qd=function(e,t){return Eo(e.saveExtraState,e.loadExtraState,t+" saveExtraState/loadExtraState")},Ia=function(e,t){return Eo(e.compose,e.decompose,t+" compose/decompose")},Eo=function(e,t,i){if(e&&t){if(typeof e!="function"||typeof t!="function")throw Error(i+" must be a function");return!0}if(!e&&!t)return!1;throw Error(i+"Must have both or neither functions")},Ra=function(e,t){const i=Zd(t,e),n=Qd(t,e);if(!i&&!n)throw Error(e+"Mutations must contain either XML hooks, or JSON hooks, or both");Ia(t,e)},bo=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},qd=function(e,t){if(t=bo(t),t.length!==e.length)return!1;for(let i=0;ii)){var n=t.getSvgXY(e.getSvgRoot());e.outputConnection?(n.x+=(e.RTL?3:-3)*i,n.y+=13*i):e.previousConnection&&(n.x+=(e.RTL?-23:23)*i,n.y+=3*i),e=ee(q.CIRCLE,{cx:n.x,cy:n.y,r:0,fill:"none",stroke:"#888","stroke-width":10},t.getParentSvg()),Oa(e,new Date,i)}},Oa=function(e,t,i){const n=(new Date().getTime()-t.getTime())/150;1e.workspace.scale)){var t=e.getHeightWidth().height;t=Math.atan(10/t)/Math.PI*180,e.RTL||(t*=-1),yr=e,Ma(e,t,new Date)}},Ma=function(e,t,i){const n=(new Date().getTime()-i.getTime())/200;let u="";1>=n&&(u=`skewX(${Math.round(Math.sin(n*Math.PI*3)*(1-n)*t)})`,br=setTimeout(Ma,10,e,t,i)),e.getSvgRoot().setAttribute("transform",`${e.getTranslation()} ${u}`)},jn=function(){yr&&(br&&(clearTimeout(br),br=null),yr.getSvgRoot().setAttribute("transform",yr.getTranslation()),yr=null)},js=function(e,t,i){const n=i.getBoundingRectangle(),u=n.right-n.left,b=zn(t.top,n.top,t.top+t.height-(n.bottom-n.top))-n.top;let G=t.left;return t=t.left+t.width-u,e.RTL?G=Math.min(t,G):t=Math.max(G,t),(e=zn(G,n.left,t)-n.left)||b?(i.moveBy(e,b),!0):!1},Na=function(e){return t=>{var i=e.getMetricsManager();if(i.hasFixedEdges()&&!e.isDragging()){var n;if(Lc.indexOf((n=t.type)!=null?n:"")!==-1){n=i.getScrollMetrics(!0);const u=ip(e,t);u&&(i=Y()||!1,z(t.group),js(e,n,u)&&!t.group&&console.warn("Moved object in bounds but there was no event group. This may break undo."),z(i))}else t.type===wn&&t.scale&&t.oldScale&&t.scale>t.oldScale&&yo(e)}}},ip=function(e,t){let i=null;switch(t.type){case wt:case Ot:(i=e.getBlockById(t.blockId))&&(i=i.getRootBlock());break;case Sn:case Ui:i=e.getCommentById(t.commentId)}return i},yo=function(e){var t=e.getMetricsManager();if(t.hasFixedEdges()&&!e.isDragging()){t=t.getScrollMetrics(!0);var i=e.getTopBoundedElements();for(let n=0,u;u=i[n];n++)js(e,t,u)}},np=function(e){const t=[];e=e.getDescendants(!1);for(let i=0,n;n=e[i];i++){const u=n.getIcons();for(let b=0;b{setTimeout(()=>{u.callback(u.scope)},0)})},{})}return i},ap=function(e,t,i){const n=qr();t=new ct(t.clientY+n.top,t.clientY+n.top,t.clientX+n.left,t.clientX+n.left),cp(e);const u=e.getSize();i&&(t.left+=u.width,t.right+=u.width,n.left+=u.width,n.right+=u.width),Ea(n,t,u,i),e.focus()},cp=function(e){var t=En();if(!t)throw Error("Attempting to create a context menu when widget div is null");t=e.render(t),Te(t,"blocklyContextMenu"),ve(t,"contextmenu",null,hp),e.focus()},hp=function(e){e.preventDefault(),e.stopPropagation()},Qs=function(){fo(vh),Ir=null},xa=function(){Rr&&(Rr.dispose(),Rr=null)},up=function(e,t){return()=>{Q();let i;try{i=$n(t,e.workspace);const n=e.getRelativeToSurfaceXY();n.x=e.RTL?n.x-s.config$$module$build$src$core$config.snapRadius:n.x+s.config$$module$build$src$core$config.snapRadius,n.y+=2*s.config$$module$build$src$core$config.snapRadius,i.moveBy(n.x,n.y)}finally{ie()}J()&&!i.isShadow()&&k(new(le(wt))(i)),i.select()}},Ba=function(e){return{text:Ie.REMOVE_COMMENT,enabled:!0,callback:function(){z(!0),e.dispose(),z(!1)}}},Pa=function(e){return{text:Ie.DUPLICATE_COMMENT,enabled:!0,callback:function(){Js(e)}}},dp=function(e,t){const i={enabled:!0};return i.text=Ie.ADD_COMMENT,i.callback=function(){const n=new St(e,Ie.WORKSPACE_COMMENT_DEFAULT_TEXT,St.DEFAULT_SIZE,St.DEFAULT_SIZE);var u=e.getInjectionDiv().getBoundingClientRect();u=new ge(t.clientX-u.left,t.clientY-u.top);const b=e.getOriginOffsetInPixels();u=ge.difference(u,b),u.scale(1/e.scale),n.moveBy(u.x,u.y),e.rendered&&(n.initSvg(),n.render(),n.select())},i},qs=function(e){let t=e.outputConnection;return(!t||e.previousConnection&&e.previousConnection.isConnected())&&(t=e.previousConnection),t},Ee=function(e,t){return" "+e+","+t+" "},Ft=function(e,t){return" "+e+t.join("")},yt=function(e,t){return" M "+e+","+t+" "},tt=function(e,t){return" m "+e+","+t+" "},Ii=function(e,t){return" l "+e+","+t+" "},Zn=function(e){return" l"+e.join("")},_e=function(e,t){return" "+e+" "+t+" "},ht=function(e,t,i,n){return e+" "+i+" "+i+" "+t+n},pp=function(e){Fa(e),wh||(wh=window.requestAnimationFrame(gp))},Fa=function(e){sl.add(e);const t=e.getParent();t?Fa(t):nl.add(e)},gp=function(){const e=new Set([...nl].map(t=>t.workspace));for(const t of nl)t.isDisposed()||t.getParent()||(Ga(t),Ua(t,t.getRelativeToSurfaceXY()),Ha(t));for(const t of e)t.resizeContents();nl.clear(),sl=new Set,wh=0},Ga=function(e){if(sl.has(e)){for(const t of e.getChildren(!1))Ga(t);e.renderEfficiently()}},Ua=function(e,t){for(const i of e.getConnections_(!1)){e=i.moveToOffset(t);const n=i.targetBlock();i.isSuperior()&&n&&(e||sl.has(n))&&Ua(n,ge.sum(t,n.relativeCoords))}},Ha=function(e){if(e.getIcons){for(const t of e.getIcons())t.computeIconLocation();for(const t of e.getChildren(!1))Ha(t)}},Va=function(){Ye.registry.register({displayText(){return Ie.UNDO},preconditionFn(e){return 0t.length?er(t):Fe(Ie.DELETE_ALL_BLOCKS.replace("%1",String(t.length)),function(i){i&&er(t)})}},scopeType:Ye.ScopeType.WORKSPACE,id:"workspaceDelete",weight:6})},fp=function(){Va(),Wa(),za(),Ya(),Ka(),Ja()},Za=function(){Ye.registry.register({displayText(){return Ie.DUPLICATE_BLOCK},preconditionFn(e){return e=e.block,!e.isInFlyout&&e.isDeletable()&&e.isMovable()?e.isDuplicatable()?"enabled":"disabled":"hidden"},callback(e){e.block&&Js(e.block)},scopeType:Ye.ScopeType.BLOCK,id:"blockDuplicate",weight:1})},Qa=function(){Ye.registry.register({displayText(e){return e.block.getCommentIcon()?Ie.REMOVE_COMMENT:Ie.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:Ye.ScopeType.BLOCK,id:"blockComment",weight:2})},qa=function(){Ye.registry.register({displayText(e){return e.block.getInputsInline()?Ie.EXTERNAL_INPUTS:Ie.INLINE_INPUTS},preconditionFn(e){if(e=e.block,!e.isInFlyout&&e.isMovable()&&!e.isCollapsed()){for(let t=1;t!n.getReturnTypes()).map(n=>[n.getName(),n.getParameters().map(u=>u.getName()),!1]);e.getBlocksByType("procedures_defnoreturn",!1).forEach(n=>{!nn(n)&&Gn(n)&&t.push(n.getProcedureDef())});const i=e.getProcedureMap().getProcedures().filter(n=>!!n.getReturnTypes()).map(n=>[n.getName(),n.getParameters().map(u=>u.getName()),!0]);return e.getBlocksByType("procedures_defreturn",!1).forEach(n=>{!nn(n)&&Gn(n)&&i.push(n.getProcedureDef())}),t.sort(rc),i.sort(rc),[t,i]},rc=function(e,t){return e[0].localeCompare(t[0],void 0,{sensitivity:"base"})},oc=function(e,t){if(t.isInFlyout)return e;for(e=e||Ie.UNNAMED_KEY||"unnamed";!_p(e,t.workspace,t);){const i=e.match(/^(.*?)(\d+)$/);e=i?i[1]+(parseInt(i[2])+1):e+"2"}return e},_p=function(e,t,i){return!lc(e,t,i)},lc=function(e,t,i){for(const n of t.getAllBlocks(!1))if(n!==i&&Gn(n)&&Nt.equals(n.getProcedureDef()[0],e))return!0;i=i&&nn(i)?i==null?void 0:i.getProcedureModel():void 0;for(const n of t.getProcedureMap().getProcedures())if(n!==i&&Nt.equals(n.getName(),e))return!0;return!1},$p=function(e){var t=this.getSourceBlock();if(!t)throw new pt;e=e.trim();const i=oc(e,t);nn(t)&&!t.isInsertionMarker()&&t.getProcedureModel().setName(i);const n=this.getValue();if(n!==e&&n!==i)for(e=t.workspace.getAllBlocks(!1),t=0;tTp(i,e)||bu(i)&&Nt.equals(i.getProcedureCall(),e))},Tp=function(e,t){return nn(e)&&!e.isProcedureDef()&&e.getProcedureModel()&&Nt.equals(e.getProcedureModel().getName(),t)},Ep=function(e){const t=O();var i=e.getProcedureDef()[0];const n=e.mutationToDom(!0);e=hc(i,e.workspace);for(let b=0,G;G=e[b];b++){i=(i=G.mutationToDom())&&Ct(i),G.domToMutation&&G.domToMutation(n);var u=G.mutationToDom();u=u&&Ct(u),i!==u&&(E(!1),k(new(le($t))(G,"mutation",null,i,u)),E(t))}},bp=function(e,t){for(const i of t.getAllBlocks(!1))if(nn(i)&&i.isProcedureDef()&&Nt.equals(i.getProcedureModel().getName(),e)||Gn(i)&&Nt.equals(i.getProcedureDef()[0],e))return i;return null},uc=function(e){return e.isDynamic},tr=function(){return $f},yp=function(){p("Blockly.blockRendering.debug.stopDebugger()","version 8","version 10","the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)"),$f=!1},Qn=function(e,t){m(pe.RENDERER,e,t)},wp=function(e){P(pe.RENDERER,e)},Sp=function(){p("Blockly.blockRendering.stopDebugger()","September 2021","September 2022","the debug renderer in @blockly/dev-tools (See https://www.npmjs.com/package/@blockly/dev-tools.)"),yp()},dc=function(e,t,i){return e=new(a(pe.RENDERER,e))(e),e.init(t,i),e},pc=function(e){Un(e.getTargetWorkspace(),void 0,"String")},gc=function(e){Un(e.getTargetWorkspace(),void 0,"Number")},fc=function(e){Un(e.getTargetWorkspace(),void 0,"Colour")},Ao=function(e){let t=[],i=document.createElement("button");return i.setAttribute("text",Ie.NEW_STRING_VARIABLE),i.setAttribute("callbackKey","CREATE_VARIABLE_STRING"),t.push(i),i=document.createElement("button"),i.setAttribute("text",Ie.NEW_NUMBER_VARIABLE),i.setAttribute("callbackKey","CREATE_VARIABLE_NUMBER"),t.push(i),i=document.createElement("button"),i.setAttribute("text",Ie.NEW_COLOUR_VARIABLE),i.setAttribute("callbackKey","CREATE_VARIABLE_COLOUR"),t.push(i),e.registerButtonCallback("CREATE_VARIABLE_STRING",pc),e.registerButtonCallback("CREATE_VARIABLE_NUMBER",gc),e.registerButtonCallback("CREATE_VARIABLE_COLOUR",fc),e=mc(e),t=t.concat(e)},mc=function(e){e=e.getAllVariables();const t=[];if(0$c(i))),t},$c=function(e){const t={id:e.getId(),name:e.getName()};return e.getTypes().length&&(t.types=e.getTypes()),t},vc=function(e,t,i,n){if(e=new e(n,i.name,i.id).setReturnTypes(i.returnTypes),!i.parameters)return e;for(const[u,b]of i.parameters.entries())e.insertParameter(Tc(t,b,n),u);return e},Tc=function(e,t,i){return e=new e(i,t.name,t.id),t.types&&e.setTypes(t.types),e},Np=function(e){const t=Object.create(null),i=o(pe.SERIALIZER,!0);for(const n in i){let u;const b=(u=i[n])==null?void 0:u.save(e);b&&(t[n]=b)}return t},Dp=function(e,t,{recordUndo:i=!1}={}){var n=o(pe.SERIALIZER,!0);if(n){n=Object.entries(n).sort((b,G)=>G[1].priority-b[1].priority);var u=O();E(i),(i=Y())||z(!0),Ve(),t instanceof _i&&t.setResizesEnabled(!1);for(const[,b]of n.reverse()){let G;(G=b)==null||G.clear(t)}for(let[b,G]of n.reverse())if(e[b]){let X;(X=G)==null||X.load(e[b],t)}t instanceof _i&&t.setResizesEnabled(!0),Qe(),k(new(le(ns))(t)),z(i),E(u)}},Ec=function(){Ze.registry.register({name:Di.ESCAPE,preconditionFn(e){return!e.options.readOnly},callback(e){return e.hideChaff(),!0},keyCodes:[Me.ESC]})},bc=function(){Ze.registry.register({name:Di.DELETE,preconditionFn(e){const t=M();return!e.options.readOnly&&t!=null&&t.isDeletable()},callback(e,t){return t.preventDefault(),Li.inProgress()?!1:(M().checkAndDelete(),!0)},keyCodes:[Me.DELETE,Me.BACKSPACE]})},yc=function(){const e=Ze.registry.createSerializedKey(Me.C,[Me.CTRL]),t=Ze.registry.createSerializedKey(Me.C,[Me.ALT]),i=Ze.registry.createSerializedKey(Me.C,[Me.META]);Ze.registry.register({name:Di.COPY,preconditionFn(n){const u=M();return!n.options.readOnly&&!Li.inProgress()&&u!=null&&u.isDeletable()&&u.isMovable()},callback(n,u){return u.preventDefault(),n.hideChaff(),Jn(M()),!0},keyCodes:[e,t,i]})},wc=function(){const e=Ze.registry.createSerializedKey(Me.X,[Me.CTRL]),t=Ze.registry.createSerializedKey(Me.X,[Me.ALT]),i=Ze.registry.createSerializedKey(Me.X,[Me.META]);Ze.registry.register({name:Di.CUT,preconditionFn(n){const u=M();return!n.options.readOnly&&!Li.inProgress()&&u!=null&&u instanceof ni&&u.isDeletable()&&u.isMovable()&&!u.workspace.isFlyout},callback(){const n=M();return n?(Jn(n),n.checkAndDelete(),!0):!1},keyCodes:[e,t,i]})},Sc=function(){const e=Ze.registry.createSerializedKey(Me.V,[Me.CTRL]),t=Ze.registry.createSerializedKey(Me.V,[Me.ALT]),i=Ze.registry.createSerializedKey(Me.V,[Me.META]);Ze.registry.register({name:Di.PASTE,preconditionFn(n){return!n.options.readOnly&&!Li.inProgress()},callback(){return!!wo()},keyCodes:[e,t,i]})},Ic=function(){const e=Ze.registry.createSerializedKey(Me.Z,[Me.CTRL]),t=Ze.registry.createSerializedKey(Me.Z,[Me.ALT]),i=Ze.registry.createSerializedKey(Me.Z,[Me.META]);Ze.registry.register({name:Di.UNDO,preconditionFn(n){return!n.options.readOnly&&!Li.inProgress()},callback(n){return n.hideChaff(),n.undo(!1),!0},keyCodes:[e,t,i]})},Rc=function(){const e=Ze.registry.createSerializedKey(Me.Z,[Me.SHIFT,Me.CTRL]),t=Ze.registry.createSerializedKey(Me.Z,[Me.SHIFT,Me.ALT]),i=Ze.registry.createSerializedKey(Me.Z,[Me.SHIFT,Me.META]),n=Ze.registry.createSerializedKey(Me.Y,[Me.CTRL]);Ze.registry.register({name:Di.REDO,preconditionFn(u){return!Li.inProgress()&&!u.options.readOnly},callback(u){return u.hideChaff(),u.undo(!0),!0},keyCodes:[e,t,i,n]})},Cc=function(){Ec(),bc(),yc(),wc(),Sc(),Ic(),Rc()},xp=function(e){return e.isSelectable()},Bp=function(e){return p("Blockly.utils.getRelativeXY","December 2021","December 2022","Blockly.utils.svgMath.getRelativeXY"),ti(e)},Pp=function(e){return p("Blockly.utils.getInjectionDivXY_","December 2021","December 2022","Blockly.utils.svgMath.getInjectionDivXY"),Ps(e)},Fp=function(e){return p("Blockly.utils.tokenizeInterpolation","December 2021","December 2022","Blockly.utils.parsing.tokenizeInterpolation"),po(e)},Gp=function(e){return p("Blockly.utils.replaceMessageReferences","December 2021","December 2022","Blockly.utils.parsing.replaceMessageReferences"),rt(e)},Up=function(e){return p("Blockly.utils.checkMessageReferences","December 2021","December 2022","Blockly.utils.parsing.checkMessageReferences"),zs(e)},Hp=function(){return p("Blockly.utils.is3dSupported","December 2021","December 2022","Blockly.utils.svgMath.is3dSupported"),xl()},Vp=function(){return p("Blockly.utils.getViewportBBox","December 2021","December 2022","Blockly.utils.svgMath.getViewportBBox"),qr()},Wp=function(e,t){return p("Blockly.utils.arrayRemove","December 2021","December 2022","Blockly.array.removeElem"),kt(e,t)},zp=function(){return p("Blockly.utils.getDocumentScroll","December 2021","December 2022","Blockly.utils.svgMath.getDocumentScroll"),eo()},Xp=function(e,t){return p("Blockly.utils.getBlockTypeCounts","December 2021","December 2022","Blockly.common.getBlockTypeCounts"),N(e,t)},Yp=function(e,t){return p("Blockly.utils.screenToWsCoordinates","December 2021","December 2022","Blockly.utils.svgMath.screenToWsCoordinates"),Bl(e,t)},Kp=function(e){return p("Blockly.utils.parseBlockColour","December 2021","December 2022","Blockly.utils.parsing.parseBlockColour"),Tn(e)},jp=function(e){p("Blockly.utils.runAfterPageLoad","December 2021","December 2022"),Ks(e)},Jp=function(e){_().hideChaff(e)},Zp=function(e){p("Blockly.resizeSvgContents","December 2021","December 2022","Blockly.WorkspaceSvg.resizeSvgContents"),Ip(e)},Qp=function(e){p("Blockly.copy","December 2021","December 2022","Blockly.clipboard.copy"),Jn(e)},qp=function(){return p("Blockly.paste","December 2021","December 2022","Blockly.clipboard.paste"),!!wo()},eg=function(e){p("Blockly.duplicate","December 2021","December 2022","Blockly.clipboard.duplicate"),Js(e)},tg=function(e){return p("Blockly.isNumber","December 2021","December 2022","Blockly.utils.string.isNumber"),aa(e)},ig=function(e){return p("Blockly.hueToHex","December 2021","December 2022","Blockly.utils.colour.hueToHex"),ho(e)},ng=function(e,t,i,n){return p("Blockly.bindEvent_","December 2021","December 2022","Blockly.browserEvents.bind"),At(e,t,i,n)},sg=function(e){return p("Blockly.unbindEvent_","December 2021","December 2022","Blockly.browserEvents.unbind"),Je(e)},rg=function(e,t,i,n,u,b){return p("Blockly.bindEventWithChecks_","December 2021","December 2022","Blockly.browserEvents.conditionalBind"),ve(e,t,i,n,u)},ye=ye||{},ye.scope={},ye.ASSUME_ES5=!1,ye.ASSUME_NO_NATIVE_MAP=!1,ye.ASSUME_NO_NATIVE_SET=!1,ye.SIMPLE_FROUND_POLYFILL=!1,ye.ISOLATE_POLYFILLS=!1,ye.FORCE_POLYFILL_PROMISE=!1,ye.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1,ye.defineProperty=ye.ASSUME_ES5||typeof Object.defineProperties=="function"?Object.defineProperty:function(e,t,i){return e==Array.prototype||e==Object.prototype||(e[t]=i.value),e},ye.getGlobal=function(e){e=[typeof globalThis=="object"&&globalThis,e,typeof window=="object"&&window,typeof self=="object"&&self,typeof si=="object"&&si];for(var t=0;t>>0,ye.propertyToPolyfillSymbol[u]=ye.IS_SYMBOL_NATIVE?ye.global.Symbol(u):ye.POLYFILL_PREFIX+i+"$"+u),ye.defineProperty(n,ye.propertyToPolyfillSymbol[u],{configurable:!0,writable:!0,value:t})))},ye.polyfill("globalThis",function(e){return e||ye.global},"es_2020","es3"),ye.polyfill("Object.getOwnPropertyDescriptors",function(e){return e||function(t){for(var i={},n=Reflect.ownKeys(t),u=0;u{const e=ag.length,t=[];for(let i=0;20>i;i++)t[i]=ag.charAt(Math.random()*e);return t.join("")}},Gm=0,No={};No.TEST_ONLY=cg,No.genUid=A,No.getNextUniqueId=F;var hg="",ir=!0,Oc=0,wt="create",Ri="delete",$t="change",Ot="move",yn="var_create",es="var_delete",nr="var_rename",sr="ui",ts="drag",rn="selected",on="click",rr="marker_move",Gi="bubble_open",or="trashcan_open",lr="toolbox_item_select",ar="theme_change",wn="viewport_change",Sn="comment_create",is="comment_delete",cr="comment_change",Ui="comment_move",ns="finished_loading",Lc=[wt,Ot,Sn,Ui],ss=[],Mc={FIRE_QUEUE:ss,fireNow:V,fireInternal:H,setGroupInternal:oe},Oe={};Oe.BLOCK_CHANGE=$t,Oe.BLOCK_CREATE=wt,Oe.BLOCK_DELETE=Ri,Oe.BLOCK_DRAG=ts,Oe.BLOCK_MOVE=Ot,Oe.BUBBLE_OPEN=Gi,Oe.BUMP_EVENTS=Lc,Oe.CHANGE=$t,Oe.CLICK=on,Oe.COMMENT_CHANGE=cr,Oe.COMMENT_CREATE=Sn,Oe.COMMENT_DELETE=is,Oe.COMMENT_MOVE=Ui,Oe.CREATE=wt,Oe.DELETE=Ri,Oe.FINISHED_LOADING=ns,Oe.MARKER_MOVE=rr,Oe.MOVE=Ot,Oe.SELECTED=rn,Oe.TEST_ONLY=Mc,Oe.THEME_CHANGE=ar,Oe.TOOLBOX_ITEM_SELECT=lr,Oe.TRASHCAN_OPEN=or,Oe.UI=sr,Oe.VAR_CREATE=yn,Oe.VAR_DELETE=es,Oe.VAR_RENAME=nr,Oe.VIEWPORT_CHANGE=wn,Oe.clearPendingUndo=K,Oe.disable=Q,Oe.disableOrphans=Re,Oe.enable=ie,Oe.filter=W,Oe.fire=k,Oe.fromJson=de,Oe.get=le,Oe.getDescendantIds=he,Oe.getGroup=Y,Oe.getRecordUndo=O,Oe.isEnabled=J,Oe.setGroup=z,Oe.setRecordUndo=E;var ke;(function(e){e[e.VALUE=1]="VALUE",e[e.STATEMENT=3]="STATEMENT",e[e.DUMMY=5]="DUMMY"})(ke||(ke={})),s.module$build$src$core$input_types={},s.module$build$src$core$input_types.inputTypes=ke;var Tt=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}},In,Do,xo,Nc;({document:In,DOMParser:Do,XMLSerializer:xo}=globalThis),Nc="https://developers.google.com/blockly/xml",s.module$build$src$core$utils$xml={},s.module$build$src$core$utils$xml.NAME_SPACE=Nc,s.module$build$src$core$utils$xml.createElement=s.createElement$$module$build$src$core$utils$xml,s.module$build$src$core$utils$xml.createTextNode=Ue,s.module$build$src$core$utils$xml.domToText=Ct,s.module$build$src$core$utils$xml.getDocument=vt,s.module$build$src$core$utils$xml.injectDependencies=je,s.module$build$src$core$utils$xml.setDocument=nt,s.module$build$src$core$utils$xml.textToDom=De,s.module$build$src$core$utils$xml.textToDomDocument=Pt;var rs="http://www.w3.org/2000/svg",hi="http://www.w3.org/1999/xhtml",Ht="http://www.w3.org/1999/xlink",Ci;(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"})(Ci||(Ci={}));var ui=null,Dc=0,Bo=null,ft={};ft.HTML_NS=hi,ft.NodeType=Ci,ft.SVG_NS=rs,ft.XLINK_NS=Ht,ft.addClass=Te,ft.containsNode=Ne,ft.createSvgElement=ee,ft.getFastTextWidth=L,ft.getFastTextWidthWithSizeString=U,ft.getTextWidth=We,ft.hasClass=ae,ft.insertAfter=be,ft.measureFontMetrics=j,ft.removeClass=xe,ft.removeClasses=Ti,ft.removeNode=ue,ft.setCssTransform=Be,ft.startTextWidthCache=Ve,ft.stopTextWidthCache=Qe;var ug=function(e,t){window.alert(e),t&&t()},dg=function(e,t){t(window.confirm(e))},pg=function(e,t,i){i(window.prompt(e,t))},gg={confirmInternal:fn},Vt={};Vt.TEST_ONLY=gg,Vt.alert=ne,Vt.confirm=Fe,Vt.prompt=Xr,Vt.setAlert=se,Vt.setConfirm=Tu,Vt.setPrompt=Eu;var Ie,xc;Ie=Object.create(null),xc=function(e){Object.keys(e).forEach(function(t){Ie[t]=e[t]})},s.module$build$src$core$msg={},s.module$build$src$core$msg.Msg=Ie,s.module$build$src$core$msg.setLocale=xc;var os=class{constructor(){this.workspaceId=void 0,this.isUiEvent=!1,this.type="",this.group=Y(),this.recordUndo=O()}toJson(){return{type:this.type,group:this.group}}fromJson(e){p("Blockly.Events.Abstract.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),this.isBlank=!1,this.group=e.group||""}static fromJson(e,t,i){return i.isBlank=!1,i.group=e.group||"",i.workspaceId=t.id,i}isNull(){return!1}run(e){}getEventWorkspace_(){let e;if(this.workspaceId&&(e=l(this.workspaceId)),!e)throw Error("Workspace is null. Event must have been generated from real Blockly events.");return e}},hr=class extends os{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){p("Blockly.Events.VarBase.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.varId=e.varId}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new hr),t.varId=e.varId,t}},Bc=class extends hr{constructor(e){super(e),this.type=yn,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){p("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,i){return t=super.fromJson(e,t,i??new Bc),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)}};m(pe.EVENT,yn,Bc);var ur=class{constructor(e,t,i,n){this.workspace=e,this.name=t,this.type=i||"",this.id_=n||A()}getId(){return this.id_}static compareByName(e,t){return e.name.localeCompare(t.name,void 0,{sensitivity:"base"})}},Po,Fo,Pc;Po="VARIABLE",Fo="ijkmnopqrstuvwxyzabcdefgh",Pc={generateUniqueNameInternal:wu},s.module$build$src$core$variables={},s.module$build$src$core$variables.CATEGORY_NAME=Po,s.module$build$src$core$variables.TEST_ONLY=Pc,s.module$build$src$core$variables.VAR_LETTER_OPTIONS=Fo,s.module$build$src$core$variables.allDeveloperVariables=yu,s.module$build$src$core$variables.allUsedVarModels=Yr,s.module$build$src$core$variables.createVariableButtonHandler=Un,s.module$build$src$core$variables.flyoutCategory=Kr,s.module$build$src$core$variables.flyoutCategoryBlocks=wl,s.module$build$src$core$variables.generateUniqueName=Sl,s.module$build$src$core$variables.generateUniqueNameFromOptions=jr,s.module$build$src$core$variables.generateVariableFieldDom=mn,s.module$build$src$core$variables.getAddedVariables=Zr,s.module$build$src$core$variables.getOrCreateVariablePackage=Ls,s.module$build$src$core$variables.getVariable=Ms,s.module$build$src$core$variables.nameUsedWithAnyType=Rl,s.module$build$src$core$variables.nameUsedWithConflictingParam=Cl,s.module$build$src$core$variables.promptName=Jr,s.module$build$src$core$variables.renameVariable=Il;var ge=class{constructor(e,t){this.x=e,this.y=t}clone(){return new ge(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 i=e.x-t.x;return e=e.y-t.y,Math.sqrt(i*i+e*e)}static magnitude(e){return Math.sqrt(e.x*e.x+e.y*e.y)}static difference(e,t){return new ge(e.x-t.x,e.y-t.y)}static sum(e,t){return new ge(e.x+t.x,e.y+t.y)}},Ai=class{constructor(e,t,i,n,u){this.workspace=e,this.editable_=this.movable_=this.deletable_=!0,this.disposed_=!1,this.isComment=!0,this.id=u&&!e.getCommentById(u)?u:A(),e.addTopComment(this),this.xy_=new ge(0,0),this.height_=i,this.width_=n,this.RTL=e.RTL,this.content_=t,Ai.fireCreateEvent(this)}dispose(){this.disposed_||(J()&&k(new(le(is))(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 ge(this.xy_.x,this.xy_.y)}moveBy(e,t){const i=new(le(Ui))(this);this.xy_.translate(e,t),i.recordNew(),k(i)}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&&(k(new(le(cr))(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=s.createElement$$module$build$src$core$utils$xml("comment");return e||(t.id=this.id),t.textContent=this.getContent(),t}static fireCreateEvent(e){if(J()){const t=Y();t||z(!0);try{k(new(le(Sn))(e))}finally{z(t)}}}static fromXml(e,t){var i=Ai.parseAttributes(e);return t=new Ai(t,i.content,i.h,i.w,i.id),i=e.getAttribute("x"),e=e.getAttribute("y"),i=i?parseInt(i,10):NaN,e=e?parseInt(e,10):NaN,isNaN(i)||isNaN(e)||t.moveBy(i,e),Ai.fireCreateEvent(t),t}static parseAttributes(e){const t=e.getAttribute("h"),i=e.getAttribute("w"),n=e.getAttribute("x"),u=e.getAttribute("y"),b=e.getAttribute("id");if(!b)throw Error("No ID present in XML comment definition.");let G;return{id:b,h:t?parseInt(t):100,w:i?parseInt(i):100,x:n?parseInt(n):NaN,y:u?parseInt(u):NaN,content:(G=e.textContent)!=null?G:""}}},di=class extends os{constructor(e){super(),this.isBlank=!0,this.recordUndo=!1,this.isUiEvent=!0,this.isBlank=typeof e>"u",this.workspaceId=e||""}},Fc=class extends di{constructor(e,t,i){super(i),this.type=rn,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){p("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,i){return t=super.fromJson(e,t,i??new Fc),t.oldElementId=e.oldElementId,t.newElementId=e.newElementId,t}};m(pe.EVENT,rn,Fc);var Um=750,fg="ontouchstart"in globalThis||!!(globalThis.document&&document.documentElement&&"ontouchstart"in document.documentElement)||!(!globalThis.navigator||!globalThis.navigator.maxTouchPoints&&!globalThis.navigator.msMaxTouchPoints),Go=null,Rn={mousedown:["pointerdown"],mouseenter:["pointerenter"],mouseleave:["pointerleave"],mousemove:["pointermove"],mouseout:["pointerout"],mouseover:["pointerover"],mouseup:["pointerup","pointercancel"],touchend:["pointerup"],touchcancel:["pointercancel"]},Uo=0,Kt={};Kt.TOUCH_ENABLED=fg,Kt.TOUCH_MAP=Rn,Kt.checkTouchIdentifier=kl,Kt.clearTouchIdentifier=bi,Kt.getTouchIdentifierFromEvent=Hn,Kt.isMouseOrTouchEvent=ku,Kt.isTouchEvent=Ou,Kt.longStart=Al,Kt.longStop=Ei,Kt.setClientFromTouch=Au,Kt.shouldHandleEvent=Ns,Kt.splitEventByTouches=Lu;var Gc,mg,_g,$g,Ho,Vo,Uc,vg,Tg,Eg;(function(e){function t(n){return i.indexOf(n.toUpperCase())!==-1}Gc=e;const i=Gc.toUpperCase();mg=t("JavaFX"),_g=t("WebKit"),$g=t("Gecko")&&!_g,Ho=t("Android"),e=globalThis.navigator&&globalThis.navigator.maxTouchPoints,Vo=t("iPad")||t("Macintosh")&&0=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}intersects(e){return!(this.left>e.right||this.righte.bottom||this.bottom{this.disposed_||(this.textarea_.focus(),this.addFocus(),this.svgRectTarget_&&Te(this.svgRectTarget_,"blocklyCommentTargetFocused"),this.svgHandleTarget_&&Te(this.svgHandleTarget_,"blocklyCommentHandleTargetFocused"))},0)}blurFocus(){this.focused_=!1,setTimeout(()=>{this.disposed_||(this.textarea_.blur(),this.removeFocus(),this.svgRectTarget_&&xe(this.svgRectTarget_,"blocklyCommentTargetFocused"),this.svgHandleTarget_&&xe(this.svgHandleTarget_,"blocklyCommentHandleTargetFocused"))},0)}static fromXmlRendered(e,t,i){Q();let n;try{const u=ki.parseAttributes(e);if(n=new St(t,u.content,u.h,u.w,u.id),t.rendered&&(n.initSvg(!0),n.render()),!isNaN(u.x)&&!isNaN(u.y))if(t.RTL){const E=i||t.getWidth();n.moveBy(E-u.x,u.y)}else n.moveBy(u.x,u.y)}finally{ie()}return ki.fireCreateEvent(n),n}};St.DEFAULT_SIZE=100,St.TOP_OFFSET=10,qt(` +`,Yc={};Yc.inject=Ol,Yc.register=ei;var ct=class{constructor(e,t,i,n){this.top=e,this.bottom=t,this.left=i,this.right=n}contains(e,t){return e>=this.left&&e<=this.right&&t>=this.top&&t<=this.bottom}intersects(e){return!(this.left>e.right||this.righte.bottom||this.bottom{this.disposed_||(this.textarea_.focus(),this.addFocus(),this.svgRectTarget_&&Te(this.svgRectTarget_,"blocklyCommentTargetFocused"),this.svgHandleTarget_&&Te(this.svgHandleTarget_,"blocklyCommentHandleTargetFocused"))},0)}blurFocus(){this.focused_=!1,setTimeout(()=>{this.disposed_||(this.textarea_.blur(),this.removeFocus(),this.svgRectTarget_&&xe(this.svgRectTarget_,"blocklyCommentTargetFocused"),this.svgHandleTarget_&&xe(this.svgHandleTarget_,"blocklyCommentHandleTargetFocused"))},0)}static fromXmlRendered(e,t,i){Q();let n;try{const u=Ai.parseAttributes(e);if(n=new St(t,u.content,u.h,u.w,u.id),t.rendered&&(n.initSvg(!0),n.render()),!isNaN(u.x)&&!isNaN(u.y))if(t.RTL){const b=i||t.getWidth();n.moveBy(b-u.x,u.y)}else n.moveBy(u.x,u.y)}finally{ie()}return Ai.fireCreateEvent(n),n}};St.DEFAULT_SIZE=100,St.TOP_OFFSET=10,ei(` .blocklyCommentForeignObject { position: relative; z-index: 0; @@ -536,12 +536,12 @@ input[type=number] { .blocklyDeleteIconShape.blocklyDeleteIconHighlighted { stroke: #fc3; } -`),r.module$build$src$core$xml={},r.module$build$src$core$xml.appendDomToWorkspace=Hu,r.module$build$src$core$xml.blockToDom=Qi,r.module$build$src$core$xml.blockToDomWithXY=Fs,r.module$build$src$core$xml.clearWorkspaceAndLoadFromXml=Uu,r.module$build$src$core$xml.deleteNext=Zu,r.module$build$src$core$xml.domToBlock=_n,r.module$build$src$core$xml.domToPrettyText=Fu,r.module$build$src$core$xml.domToText=wi,r.module$build$src$core$xml.domToVariables=Gl,r.module$build$src$core$xml.domToWorkspace=Hn,r.module$build$src$core$xml.textToDom=Gu,r.module$build$src$core$xml.variablesToDom=Pl,r.module$build$src$core$xml.workspaceToDom=xu;var dr=class extends Error{},Ag=class extends dr{constructor(e){super("Expected to find a 'type' property, defining the block type"),this.state=e}},pr=class extends dr{constructor(e,t,i){super(`The block ${t.toDevString()} is missing a(n) ${e} -connection`),this.block=t,this.state=i}},Og=class extends dr{constructor(e,t,i,n){super(`The block ${i.toDevString()} could not connect its -${t} to its parent, because: ${e}`),this.childBlock=i,this.childState=n}},Lg=class extends dr{constructor(e){super(`Encountered a real block which is defined as a child of a shadow +`),s.module$build$src$core$xml={},s.module$build$src$core$xml.appendDomToWorkspace=Uu,s.module$build$src$core$xml.blockToDom=Qi,s.module$build$src$core$xml.blockToDomWithXY=Fs,s.module$build$src$core$xml.clearWorkspaceAndLoadFromXml=Gu,s.module$build$src$core$xml.deleteNext=Ju,s.module$build$src$core$xml.domToBlock=$n,s.module$build$src$core$xml.domToPrettyText=Pu,s.module$build$src$core$xml.domToText=wi,s.module$build$src$core$xml.domToVariables=Gl,s.module$build$src$core$xml.domToWorkspace=Vn,s.module$build$src$core$xml.textToDom=Fu,s.module$build$src$core$xml.variablesToDom=Pl,s.module$build$src$core$xml.workspaceToDom=Du;var dr=class extends Error{},Ag=class extends dr{constructor(e){super("Expected to find a 'type' property, defining the block type"),this.state=e}},pr=class extends dr{constructor(e,t,i){super(`The block ${t.toDevString()} is missing a(n) ${e} +connection`),this.block=t,this.state=i}},kg=class extends dr{constructor(e,t,i,n){super(`The block ${i.toDevString()} could not connect its +${t} to its parent, because: ${e}`),this.childBlock=i,this.childState=n}},Og=class extends dr{constructor(e){super(`Encountered a real block which is defined as a child of a shadow block. It is an invariant of Blockly that shadow blocks only have shadow -children`),this.state=e}},ls={};ls.BadConnectionCheck=Og,ls.DeserializationError=dr,ls.MissingBlockType=Ag,ls.MissingConnection=pr,ls.RealChildOfShadow=Lg;var Mg=100,Ng=75,Dg=50,Xo={};Xo.BLOCKS=Dg,Xo.PROCEDURES=Ng,Xo.VARIABLES=Mg;var Kc={};Kc.register=io,Kc.unregister=Qu;var xg=class{constructor(){this.priority=Dg}save(e){const t=[];for(const i of e.getTopBlocks(!1))(e=Si(i,{addCoordinates:!0,doFullSerialization:!1}))&&t.push(e);return t.length?{languageVersion:0,blocks:t}:null}load(e,t){e=e.blocks;for(const i of e)qi(i,t,{recordUndo:L()})}clear(e){for(const t of e.getTopBlocks(!1))t.dispose(!1)}};io("blocks",new xg);var gr={};gr.BlockSerializer=xg,gr.append=qi,gr.appendInternal=no,gr.save=Si;var as=class extends rs{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){p("Blockly.Events.BlockBase.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.blockId=e.blockId}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new as),t.blockId=e.blockId,t}},jc=class extends as{constructor(e){super(e),this.type=wt,e&&(e.isShadow()&&(this.recordUndo=!1),this.xml=Fs(e),this.ids=he(e),this.json=Si(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=wi(this.xml),e.ids=this.ids,e.json=this.json,this.recordUndo||(e.recordUndo=this.recordUndo),e}fromJson(e){p("Blockly.Events.BlockCreate.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.xml=De(e.xml),this.ids=e.ids,this.json=e.json,e.recordUndo!==void 0&&(this.recordUndo=e.recordUndo)}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new jc),t.xml=De(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)qi(this.json,t);else for(e=0;e"u"?"":t,this.oldValue=typeof i>"u"?"":i,this.newValue=typeof n>"u"?"":n}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}};m(pe.EVENT,sr,Pg);var Rn=class extends as{constructor(e,t,i,n,u){super(e),this.type=$t,e&&(this.element=t,this.name=i||void 0,this.oldValue=n,this.newValue=u)}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){p("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,i){return t=super.fromJson(e,t,i??new Rn),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 i=Rn.getExtraBlockState_(t);t.loadExtraState?t.loadExtraState(JSON.parse(e||"{}")):t.domToMutation&&t.domToMutation(De(e||"")),O(new Rn(t,"mutation",null,i,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())?wi(e):""}};m(pe.EVENT,$t,Rn);var Jc=class extends as{constructor(e){if(super(e),this.type=Ri,e){if(e.getParent())throw Error("Connected blocks cannot be deleted.");e.isShadow()&&(this.recordUndo=!1),this.oldXml=Fs(e),this.ids=he(e),this.wasShadow=e.isShadow(),this.oldJson=Si(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=wi(this.oldXml),e.ids=this.ids,e.wasShadow=this.wasShadow,e.oldJson=this.oldJson,this.recordUndo||(e.recordUndo=this.recordUndo),e}fromJson(e){p("Blockly.Events.BlockDelete.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.oldXml=De(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,i){return t=super.fromJson(e,t,i??new Jc),t.oldXml=De(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;eu.top?ta(i,n,u,E):t+E.heightdocument.documentElement.clientTop?ta(i,n,u,E):vd(e,u,E)}},ut={};ut.ANIMATION_TIME=jo,ut.ARROW_HORIZONTAL_PADDING=Fg,ut.ARROW_SIZE=fr,ut.BORDER_SIZE=Qc,ut.PADDING_Y=qc,ut.TEST_ONLY=ih,ut.clearContent=so,ut.createDom=Yl,ut.getContentDiv=zn,ut.getOwner=jl,ut.getPositionX=Us,ut.hide=oo,ut.hideIfOwner=Xn,ut.hideWithoutAnimation=oi,ut.isVisible=ia,ut.repositionForWindowResize=Td,ut.setBoundsElement=Kl,ut.setColour=ro,ut.show=ql,ut.showPositionedByBlock=$d,ut.showPositionedByField=Gs;var mr=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,i;i=e[t];t++)this.unregisterMarker(i);this.markers.clear(),this.cursor_&&(this.cursor_.dispose(),this.cursor_=null)}};mr.LOCAL_MARKER="local_marker_1",r.module$build$src$core$utils$string={},r.module$build$src$core$utils$string.commonWordPrefix=sa,r.module$build$src$core$utils$string.commonWordSuffix=ra,r.module$build$src$core$utils$string.isNumber=aa,r.module$build$src$core$utils$string.shortestStringLength=Hs,r.module$build$src$core$utils$string.startsWith=Ed,r.module$build$src$core$utils$string.wrap=oa;var Jo=void 0,_r=!1,ps=!1,Ug=50,Hg=0,An=0,nh=0,sh=0,ti=null,$r=null,rh=0,oh=10,Vg=10,Wg=750,Zo=5,gt=null,dt={};dt.HOVER_MS=Wg,dt.LIMIT=Ug,dt.MARGINS=Zo,dt.OFFSET_X=rh,dt.OFFSET_Y=oh,dt.RADIUS_OK=Vg,dt.bindMouseEvents=Vs,dt.block=ga,dt.createDom=ha,dt.dispose=pa,dt.getCustomTooltip=Sd,dt.getDiv=Rd,dt.getTooltipOfObject=Yn,dt.hide=en,dt.isVisible=Id,dt.setCustomTooltip=wd,dt.unbindMouseEvents=ua,dt.unblock=fa;var lh=.45,ah=.65,zg={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"},It={};It.blend=$n,It.getHsvSaturation=ma,It.getHsvValue=_a,It.hexToRgb=ao,It.hsvToHex=co,It.hueToHex=ho,It.names=zg,It.parse=tn,It.rgbToHex=Ws,It.setHsvSaturation=Nd,It.setHsvValue=Dd;var vr={};vr.checkMessageReferences=zs,vr.parseBlockColour=vn,vr.replaceMessageReferences=rt,vr.tokenizeInterpolation=po;var Qo=null,qo=null,gs="",fs="",pi,gi={};gi.createDom=$a,gi.getDiv=Tn,gi.hide=li,gi.hideIfOwner=fo,gi.isVisible=va,gi.positionWithAnchor=Ea,gi.show=go,gi.testOnly_setDiv=xd;var Pe=class{constructor(e,t,i){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 Tt(0,0),e!==Pe.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(e),t&&this.setValidator(t))}configure_(e){e.tooltip&&this.setTooltip(rt(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_=ee(q.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_=ee(q.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_=ee(q.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.");Vs(e),this.mouseDownWrapper_=ve(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(Pe),e!==null?e:this.getValue()}loadState(e){this.loadLegacyState(Pe,e)||this.setValue(e)}saveLegacyState(e){return e.prototype.saveState===this.saveState&&e.prototype.toXml!==this.toXml?(e=r.createElement$$module$build$src$core$utils$xml("field"),e.setAttribute("name",this.name||""),Ct(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(De(t)),!0):!1}dispose(){Xn(this),fo(this);let e;(e=this.getSourceBlock())!=null&&e.isDeadOrDying()||ue(this.fieldGroup_),this.disposed=!0}updateEditable(){const e=this.fieldGroup_,t=this.getSourceBlock();this.EDITABLE&&e&&t&&(this.enabled_&&t.isEditable()?(Te(e,"blocklyEditableText"),xe(e,"blocklyNonEditableText"),e.style.cursor=this.CURSOR):(Te(e,"blocklyNonEditableText"),xe(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_!==Pe.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 i=2*e,n=t.FIELD_TEXT_HEIGHT,u=0;this.textElement_&&(u=M(this.textElement_,t.FIELD_TEXT_FONTSIZE,t.FIELD_TEXT_FONTWEIGHT,t.FIELD_TEXT_FONTFAMILY),i+=u),this.borderRect_&&(n=Math.max(n,t.FIELD_BORDER_RECT_HEIGHT)),this.size_.height=n,this.size_.width=i,this.positionTextElement_(e,u),this.positionBorderRect_()}positionTextElement_(e,t){if(this.textElement_){var i=this.getConstants(),n=this.size_.height/2,u;this.textElement_.setAttribute("x",String((u=this.getSourceBlock())!=null&&u.RTL?this.size_.width-t-e:e)),this.textElement_.setAttribute("y",String(i.FIELD_TEXT_BASELINE_CENTER?n:n-i.FIELD_TEXT_HEIGHT/2+i.FIELD_TEXT_BASELINE))}}positionBorderRect_(){this.borderRect_&&(this.borderRect_.setAttribute("width",String(this.size_.width)),this.borderRect_.setAttribute("height",String(this.size_.height)),this.borderRect_.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.borderRect_.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getSize(){return this.isVisible()?(this.isDirty_?(this.render_(),this.isDirty_=!1):this.visible_&&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 Tt(0,0)}getScaledBBox(){let e;var t=this.getSourceBlock();if(!t)throw new pt;if(this.borderRect_){var i=this.borderRect_.getBoundingClientRect();e=Zi(this.borderRect_),t=i.width,i=i.height}else{i=this.sourceBlock_.getHeightWidth();const n=t.workspace.scale;e=this.getAbsoluteXY_(),t=(i.width+1)*n,i=(i.height+1)*n,Hc?(e.x+=1.5*n,e.y+=1.5*n):(e.x-=.5*n,e.y-=.5*n)}return new ct(e.y,e.y+i,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,Pe.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(e+="‏"),e):Pe.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 i;t=(i=this.getValidator())==null?void 0:i.call(this,e),i=this.processValidation_(e,t),i instanceof Error||(e=this.sourceBlock_,e&&e.disposed||(t=this.getValue(),t===i?this.doValueUpdate_(i):(this.doValueUpdate_(i),e&&J()&&O(new(le($t))(e,"field",this.name||null,t,i)),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 Yn(e||{tooltip:this.tooltip_})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return Zi(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let e=null;const t=this.getSourceBlock();if(!t)throw new pt;const i=t.inputList;for(let n=0;ne?this.menuItems.length:e,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(e,t){e+=t;let i;for(;i=this.menuItems[e];){if(i.isEnabled()){this.setHighlighted(i);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 i=new ge(e.clientX,e.clientY);if(1>ge.distance(t,i))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=Bs(e);return t.height=e.scrollHeight,t}},uh=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=F(),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 i=document.createElement("div");i.className="blocklyMenuItemCheckbox goog-menuitem-checkbox",t.appendChild(i)}return i=this.content,typeof this.content=="string"&&(i=document.createTextNode(this.content)),t.appendChild(i),e.appendChild(t),this.roleName&&ai(e,this.roleName),st(e,it.SELECTED,this.checkable&&this.checked||!1),st(e,it.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?(Te(t,"blocklyMenuItemHighlight"),Te(t,"goog-menuitem-highlight")):(xe(t,"blocklyMenuItemHighlight"),xe(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)}},Oi=class extends Pe{constructor(e,t,i){super(Pe.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!==Pe.SKIP_SETUP&&(Array.isArray(e)?(ba(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],i&&this.configure_(i),this.setValue(this.selectedOption_[1]),t&&this.setValidator(t))}fromXml(e){this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e.textContent)}loadState(e){this.loadLegacyState(Oi,e)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot(),this.createTextElement_(),this.imageElement_=ee(q.IMAGE,{},this.fieldGroup_),this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_(),this.borderRect_&&Te(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_=ee(q.TSPAN,{},this.textElement_);let e;this.arrow_.appendChild(document.createTextNode((e=this.getSourceBlock())!=null&&e.RTL?Oi.ARROW_CHAR+" ":" "+Oi.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_=ee(q.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_),this.svgArrow_.setAttributeNS(Ht,"xlink:href",this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(e){var t=this.getSourceBlock();if(!t)throw new pt;this.dropdownCreate_(),this.menu_.openingCoords=e&&typeof e.clientX=="number"?new ge(e.clientX,e.clientY):null,so(),e=this.menu_.render(zn()),Te(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,ro(e,t)),Gs(this,this.dropdownDispose_.bind(this)),this.menu_.focus(),this.selectedMenuItem_&&(this.menu_.setHighlighted(this.selectedMenuItem_),Qr(this.selectedMenuItem_.getElement(),zn(),!0)),this.applyColour()}dropdownCreate_(){const e=this.getSourceBlock();if(!e)throw new pt;const t=new hh;t.setRole(Wt.LISTBOX),this.menu_=t;const i=this.getOptions(!1);this.selectedMenuItem_=null;for(let u=0;ut[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,i;i=e[t];t++)i[1]===this.value_&&(this.selectedOption_=i)}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 pt;this.imageElement_.style.display="",this.imageElement_.setAttributeNS(Ht,"xlink:href",e.src),this.imageElement_.setAttribute("height",String(e.height)),this.imageElement_.setAttribute("width",String(e.width));const i=Number(e.height);e=Number(e.width);var n=!!this.borderRect_;const u=Math.max(n?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,i+Km);n=n?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let E;E=this.svgArrow_?this.positionSVGArrow_(e+n,u/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):M(this.arrow_,this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY),this.size_.width=e+E+2*n,this.size_.height=u;let G=0;t.RTL?this.imageElement_.setAttribute("x",`${n+E}`):(G=e+E,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement_.setAttribute("x",`${n}`)),this.imageElement_.setAttribute("y",String(u/2-i/2)),this.positionTextElement_(G+n,e+E)}renderSelectedText_(){this.getTextContent().nodeValue=this.getDisplayText_();var e=this.getTextElement();Te(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 i=M(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 n=0;this.svgArrow_&&(n=this.positionSVGArrow_(i+t,e/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2)),this.size_.width=i+n+2*t,this.size_.height=e,this.positionTextElement_(t,i)}positionSVGArrow_(e,t){if(!this.svgArrow_)return 0;const i=this.getSourceBlock();if(!i)throw new pt;const n=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,u=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,E=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow_.setAttribute("transform","translate("+(i.RTL?n:e+u)+","+t+")"),E+u}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)}};Oi.CHECKMARK_OVERHANG=25,Oi.MAX_MENU_HEIGHT_VH=.45,Oi.ARROW_CHAR="▾";var Ym=5,Km=2*Ym;Xt("field_dropdown",Oi);var dh=class extends di{constructor(e,t,i){super(e?e.workspace.id:void 0),this.type=Gi,e&&(this.blockId=e.id,this.isOpen=t,this.bubbleType=i)}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){p("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,i){return t=super.fromJson(e,t,i??new dh),t.isOpen=e.isOpen,t.bubbleType=e.bubbleType,t.blockId=e.blockId,t}},ph;(function(e){e.MUTATOR="mutator",e.COMMENT="comment",e.WARNING="warning"})(ph||(ph={})),m(pe.EVENT,Gi,dh);var ot=class{constructor(e,t,i,n,u){this.workspace=e,this.horizontal=t,this.oldHostMetrics=null,this.ratio=1,this.origin=new ge(0,0),this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0,this.containerVisible=this.isHandleVisible=!0,this.position=new ge(0,0),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.pair=i||!1,this.margin=u!==void 0?u:ot.DEFAULT_SCROLLBAR_MARGIN,e="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical"),n&&(e+=" "+n),this.outerSvg=ee(q.SVG,{class:e}),n=ee(q.G,{},this.outerSvg),this.svgBackground=ee(q.RECT,{class:"blocklyScrollbarBackground"},n),e=Math.floor((ot.scrollbarThickness-5)/2),this.svgHandle=ee(q.RECT,{class:"blocklyScrollbarHandle",rx:e,ry:e},n),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarColour","fill"),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarOpacity","fill-opacity"),be(this.outerSvg,this.workspace.getParentSvg()),this.setInitialThickness(),t?(this.lengthAttribute_="width",this.positionAttribute_="x"):(this.lengthAttribute_="height",this.positionAttribute_="y"),this.onMouseDownBarWrapper_=ve(this.svgBackground,"pointerdown",this,this.onMouseDownBar),this.onMouseDownHandleWrapper_=ve(this.svgHandle,"pointerdown",this,this.onMouseDownHandle)}setInitialThickness(){const e=ot.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(),je(this.onMouseDownBarWrapper_),je(this.onMouseDownHandleWrapper_),ue(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,Be(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&&ot.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-=ot.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),t=e.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(t+=ot.scrollbarThickness),this.setPosition(t,e.absoluteTop+e.viewHeight-ot.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 i=this.scrollbarLength-this.handleLength;e=(e.viewLeft-e.scrollLeft)/t*i,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=i/t}}resizeVertical(e){this.requiresViewResize(e)?this.resizeViewVertical(e):this.resizeContentVertical(e)}resizeViewVertical(e){let t=e.viewHeight-2*this.margin;this.pair&&(t-=ot.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),this.setPosition(this.workspace.RTL?e.absoluteLeft+this.margin:e.absoluteLeft+e.viewWidth-ot.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 i=this.scrollbarLength-this.handleLength;e=(e.viewTop-e.scrollTop)/t*i,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=i/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(),bi(),this.cleanUp(),Bi(e))e.stopPropagation();else{var t=mn(e,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());t=this.horizontal?t.x:t.y;var i=Ps(this.svgHandle);i=this.horizontal?i.x:i.y;var n=this.handlePosition,u=.95*this.handleLength;t<=i?n-=u:t>=i+this.handleLength&&(n+=u),this.setHandlePosition(this.constrainHandlePosition(n)),this.updateMetrics(),e.stopPropagation(),e.preventDefault()}}onMouseDownHandle(e){this.workspace.markFocused(),this.cleanUp(),Bi(e)?e.stopPropagation():(this.startDragHandle=this.handlePosition,this.workspace.setupDragSurface(),this.startDragMouse=this.horizontal?e.clientX:e.clientY,this.onMouseUpWrapper_=ve(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=ve(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(),bi(),this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(je(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(je(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 ge(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}};ot.scrollbarThickness=mg?25:15,ot.DEFAULT_SCROLLBAR_MARGIN=.5;var ke=class{constructor(e,t,i,n,u,E){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_=i,i=ke.ARROW_ANGLE,this.workspace_.RTL&&(i=-i),this.arrowRadians=Vn(i),e.getBubbleCanvas().appendChild(this.createDom(t,!(!u||!E))),this.setAnchorLocation(n),u&&E||(e=this.content_.getBBox(),u=e.width+2*ke.BORDER_WIDTH,E=e.height+2*ke.BORDER_WIDTH),this.setBubbleSize(u,E),this.positionBubble(),this.renderArrow(),this.rendered=!0}createDom(e,t){this.bubbleGroup=ee(q.G,{});var i={filter:"url(#"+this.workspace_.getRenderer().getConstants().embossFilterId+")"};return yg&&(i={}),i=ee(q.G,i,this.bubbleGroup),this.bubbleArrow=ee(q.PATH,{},i),this.bubbleBack=ee(q.RECT,{class:"blocklyDraggable",x:0,y:0,rx:ke.BORDER_WIDTH,ry:ke.BORDER_WIDTH},i),t?(this.resizeGroup=ee(q.G,{class:this.workspace_.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.bubbleGroup),t=2*ke.BORDER_WIDTH,ee(q.POLYGON,{points:`0,${t} ${t},${t} ${t},0`},this.resizeGroup),ee(q.LINE,{class:"blocklyResizeLine",x1:t/3,y1:t-1,x2:t-1,y2:t/3},this.resizeGroup),ee(q.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=ve(this.bubbleBack,"pointerdown",this,this.bubbleMouseDown),this.resizeGroup&&(this.onMouseDownResizeWrapper=ve(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(),ke.unbindDragEvents(),Bi(e)||(this.workspace_.startDrag(e,new ge(this.workspace_.RTL?-this.width:this.width,this.height)),ke.onMouseUpWrapper=ve(document,"pointerup",this,ke.bubbleMouseUp),ke.onMouseMoveWrapper=ve(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),i=this.getOptimalRelativeTop(e),n=this.shape_.getBBox();const u={x:t,y:-this.height-this.workspace_.getRenderer().getConstants().MIN_BLOCK_HEIGHT},E={x:-this.width-30,y:i};i={x:n.width,y:i};var G={x:t,y:n.height};t=n.widthe.width)return t;if(this.workspace_.RTL){var i=this.anchorXY.x-t,n=e.left+e.width;e=e.left+ot.scrollbarThickness/this.workspace_.scale,i-this.widthn&&(t=-(n-this.anchorXY.x))}else{i=t+this.anchorXY.x,n=i+this.width;const u=e.left;e=e.left+e.width-ot.scrollbarThickness/this.workspace_.scale,ie&&(t=e-this.anchorXY.x-this.width)}return t}getOptimalRelativeTop(e){let t=-this.height/4;if(this.height>e.height)return t;const i=this.anchorXY.y+t,n=i+this.height,u=e.top;e=e.top+e.height-ot.scrollbarThickness/this.workspace_.scale;const E=this.anchorXY.y;return ie&&(t=e-E-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 i;(i=this.bubbleGroup)==null||i.setAttribute("transform","translate("+e+","+t+")")}setDragging(e){!e&&this.moveCallback&&this.moveCallback()}getBubbleSize(){return new Tt(this.width,this.height)}setBubbleSize(e,t){const i=2*ke.BORDER_WIDTH;e=Math.max(e,i+45),t=Math.max(t,i+20),this.width=e,this.height=t;let n;(n=this.bubbleBack)==null||n.setAttribute("width",`${e}`);let u;(u=this.bubbleBack)==null||u.setAttribute("height",`${t}`),this.resizeGroup&&(this.workspace_.RTL?this.resizeGroup.setAttribute("transform","translate("+2*ke.BORDER_WIDTH+","+(t-i)+") scale(-1 1)"):this.resizeGroup.setAttribute("transform","translate("+(e-i)+","+(t-i)+")")),this.autoLayout&&this.layoutBubble(),this.positionBubble(),this.renderArrow(),this.resizeCallback&&this.resizeCallback()}renderArrow(){const e=[];var t=this.width/2,i=this.height/2,n=-this.relativeLeft,u=-this.relativeTop;if(t===n&&i===u)e.push("M "+t+","+i);else{u-=i,n-=t,this.workspace_.RTL&&(n*=-1);var E=Math.sqrt(u*u+n*n),G=Math.acos(n/E);0>u&&(G=2*Math.PI-G);var X=G+Math.PI/2;X>2*Math.PI&&(X-=2*Math.PI);var re=Math.sin(X);const at=Math.cos(X);var me=this.getBubbleSize();X=(me.width+me.height)/ke.ARROW_THICKNESS,X=Math.min(X,me.width,me.height)/4,me=1-ke.ANCHOR_RADIUS/E,n=t+me*n,u=i+me*u,me=t+X*at;const zt=i+X*re;t-=X*at,i-=X*re,re=G+this.arrowRadians,re>2*Math.PI&&(re-=2*Math.PI),G=Math.sin(re)*E/ke.ARROW_BEND,E=Math.cos(re)*E/ke.ARROW_BEND,e.push("M"+me+","+zt),e.push("C"+(me+E)+","+(zt+G)+" "+n+","+u+" "+n+","+u),e.push("C"+n+","+u+" "+(t+E)+","+(i+G)+" "+t+","+i)}e.push("z");let lt;(lt=this.bubbleArrow)==null||lt.setAttribute("d",e.join(" "))}setColour(e){let t;(t=this.bubbleBack)==null||t.setAttribute("fill",e);let i;(i=this.bubbleArrow)==null||i.setAttribute("fill",e)}dispose(){this.onMouseDownBubbleWrapper&&je(this.onMouseDownBubbleWrapper),this.onMouseDownResizeWrapper&&je(this.onMouseDownResizeWrapper),ke.unbindDragEvents(),ue(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 ge(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(){ke.onMouseUpWrapper&&(je(ke.onMouseUpWrapper),ke.onMouseUpWrapper=null),ke.onMouseMoveWrapper&&(je(ke.onMouseMoveWrapper),ke.onMouseMoveWrapper=null)}static bubbleMouseUp(e){bi(),ke.unbindDragEvents()}static textToDom(e){const t=ee(q.TEXT,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",y:ke.BORDER_WIDTH});e=e.split(` -`);for(let i=0;ie||Math.abs(this.workspaceHeight-u)>e)&&(this.workspaceWidth=n,this.workspaceHeight=u,this.bubble_.setBubbleSize(n+e,u+e),this.svgDialog.setAttribute("width",`${n}`),this.svgDialog.setAttribute("height",`${u}`),this.workspace_.setCachedParentSvgSize(n,u)),E&&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 ke(t.workspace,this.createEditor(),t.pathObject.svgPath,this.iconXY_,null,null);var i=this.workspace_;this.bubble_.setSvgId(t.id),this.bubble_.registerMoveEvent(this.onBubbleMove.bind(this));var n=i.options.languageTree;const u=i.getFlyout();n&&(u.init(i),u.show(n)),this.rootBlock=t.decompose(i),n=this.rootBlock.getDescendants(!1);for(let G=0,X;X=n[G];G++)X.render();this.rootBlock.setMovable(!1),this.rootBlock.setDeletable(!1);let E;if(u?(n=2*u.CORNER_RADIUS,E=this.rootBlock.RTL?u.getWidth()+n:n):E=n=16,t.RTL&&(E=-E),this.rootBlock.moveBy(E,n),t.saveConnections){const G=this.rootBlock;t.saveConnections(G),this.sourceListener=()=>{const X=this.getBlock();X.saveConnections&&X.saveConnections(G)},t.workspace.addChangeListener(this.sourceListener)}this.resizeBubble(),n=this.workspaceChanged.bind(this),i.addChangeListener(n),u&&u.getWorkspace().addChangeListener(n),this.updateWorkspace(),this.applyColour()}else this.svgDialog=null,this.workspace_.dispose(),this.rootBlock=this.workspace_=null,(i=this.bubble_)==null||i.dispose(),this.bubble_=null,this.workspaceHeight=this.workspaceWidth=0,this.sourceListener&&(t.workspace.removeChangeListener(this.sourceListener),this.sourceListener=null);O(new(le(Gi))(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===wt||e.type===$t&&e.element==="disabled"}updateWorkspace(){if(!this.workspace_.isDragging()){var e=this.workspace_.getTopBlocks(!1);for(let n=0,u;u=e[n];n++){var t=u.getRelativeToSurfaceXY();if(20>t.y&&u.moveBy(0,20-t.y),u.RTL){var i=-20;const E=this.workspace_.getFlyout();E&&(i-=E.getWidth()),t.x>i&&u.moveBy(i-t.x,0)}else 20>t.x&&u.moveBy(20-t.x,0)}}if(this.rootBlock&&this.rootBlock.workspace===this.workspace_){(e=Y())||z(!0);const n=this.getBlock();if(t=Rn.getExtraBlockState_(n),n.compose(this.rootBlock),i=Rn.getExtraBlockState_(n),t!==i){O(new(le($t))(n,"mutation",null,t,i));const u=Y();setTimeout(function(){const E=Y();z(u),n.bumpNeighbours(),z(E)},r.config$$module$build$src$core$config.bumpDelay)}this.workspace_.isDragging()||setTimeout(()=>this.resizeBubble(),0),z(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 i=0,n;n=t[i];i++)n.setStyle(n.getStyleName());if(e=e.getFlyout()){e=e.getWorkspace().getAllBlocks(!1);for(let i=0,n;n=e[i];i++)n.setStyle(n.getStyleName())}}}static reconnect(e,t,i){if(!e||!e.getSourceBlock().workspace)return!1;i=t.getInput(i).connection;const n=e.targetBlock();return n&&n!==t||!i||i.targetConnection===e?!1:(i.isConnected()&&i.disconnect(),i.connect(e),!0)}static findParentWs(e){let t=null;if(e&&e.options){const i=e.options.parentWorkspace;e.isFlyout?i&&i.options&&(t=i.options.parentWorkspace):i&&(t=i)}return t}},jg={},jg.Mutator=r.Mutator$$module$build$src$core$mutator;var ms=Object.create(null),Zm={allExtensions:ms};r.register$$module$build$src$core$extensions("parent_tooltip_when_inline",ip),r.module$build$src$core$extensions={},r.module$build$src$core$extensions.TEST_ONLY=Zm,r.module$build$src$core$extensions.apply=To,r.module$build$src$core$extensions.buildTooltipForDropdown=r.buildTooltipForDropdown$$module$build$src$core$extensions,r.module$build$src$core$extensions.buildTooltipWithFieldText=r.buildTooltipWithFieldText$$module$build$src$core$extensions,r.module$build$src$core$extensions.isRegistered=Sa,r.module$build$src$core$extensions.register=r.register$$module$build$src$core$extensions,r.module$build$src$core$extensions.registerMixin=jd,r.module$build$src$core$extensions.registerMutator=r.registerMutator$$module$build$src$core$extensions,r.module$build$src$core$extensions.runAfterPageLoad=Ks,r.module$build$src$core$extensions.unregister=Jd;var hn=class extends Pe{constructor(e,t,i){super(Pe.SKIP_SETUP),this.class_=null,this.EDITABLE=!1,e!==Pe.SKIP_SETUP&&(i?this.configure_(i):this.class_=t||null,this.setValue(e))}configure_(e){super.configure_(e),e.class&&(this.class_=e.class)}initView(){this.createTextElement_(),this.class_&&Te(this.getTextElement(),this.class_)}doClassValidation_(e){return e==null?null:`${e}`}setClass(e){this.textElement_&&(this.class_&&xe(this.textElement_,this.class_),e&&Te(this.textElement_,e)),this.class_=e}static fromJson(e){return new this(rt(e.text),void 0,e)}};Xt("field_label",hn),hn.prototype.DEFAULT_VALUE="";var _s=class{constructor(e,t,i,n){if(this.type=e,this.name=t,this.connection=n,this.fieldRow=[],this.align=r.Align$$module$build$src$core$input.LEFT,this.visible=!0,e!==Ae.DUMMY&&!t)throw Error("Value inputs and statement inputs must have non-empty name.");this.sourceBlock=i}getSourceBlock(){return this.sourceBlock}appendField(e,t){return this.insertFieldAt(this.fieldRow.length,e,t),this}insertFieldAt(e,t,i){if(0>e||e>this.fieldRow.length)throw Error("index "+e+" out of bounds.");return(t||t===""&&i)&&(typeof t=="string"&&(t=mo({type:"field_label",text:t})),t.setSourceBlock(this.sourceBlock),this.sourceBlock.rendered&&(t.init(),t.applyColour()),t.name=i,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 i=0,n;n=this.fieldRow[i];i++)if(n.name===e)return n.dispose(),this.fieldRow.splice(i,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 n=0,u;u=this.fieldRow[n];n++)u.setVisible(e);if(this.connection){var i=this.connection;e?t=i.startTrackingAll():i.stopTrackingAll(),(i=i.targetBlock())&&(i.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;ee.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 i=0,n;n=t.fieldRow[i];i++)n.initModel&&n.initModel()}unplug(e){this.outputConnection&&this.unplugFromRow_(e),this.previousConnection&&this.unplugFromStack_(e)}unplugFromRow_(e){let t=null,i;(i=this.outputConnection)!=null&&i.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(n=n+(i==="("||u===")"?"":" ")+u,i=u[u.length-1],n),""),t=t.trim()||"???",e&&t.length>e&&(t=t.substring(0,e-3)+"..."),t}toTokens(e="?"){const t=[];for(const n of this.inputList)if(n.name!=cs){for(const u of n.fieldRow)t.push(u.getText());if(n.connection){const u=n.connection.targetBlock();if(u){var i=n.connection;let E=i.getCheck();!E&&i.targetConnection&&(E=i.targetConnection.getCheck()),(i=!!E&&(E.indexOf("Boolean")!==-1||E.indexOf("Number")!==-1))&&t.push("("),t.push(...u.toTokens(e)),i&&t.push(")")}else t.push(e)}}return t}appendValueInput(e){return this.appendInput_(Ae.VALUE,e)}appendStatementInput(e){return this.appendInput_(Ae.STATEMENT,e)}appendDummyInput(e){return this.appendInput_(Ae.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 i=0;e["message"+i]!==void 0;)this.interpolate_(e["message"+i],e["args"+i]||[],e["lastDummyAlign"+i],t),i++;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&&(i=rt(e.tooltip),this.setTooltip(i)),e.enableContextMenu!==void 0&&(this.contextMenu=!!e.enableContextMenu),e.suppressPrefixSuffix!==void 0&&(this.suppressPrefixSuffix=!!e.suppressPrefixSuffix),e.helpUrl!==void 0&&(i=rt(e.helpUrl),this.setHelpUrl(i)),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&&To(e.mutator,this,!0),e=e.extensions,Array.isArray(e))for(t=0;tE||E>t)throw Error('Block "'+this.type+'": Message index %'+E+" out of range.");if(i[E])throw Error('Block "'+this.type+'": Message index %'+E+" duplicated.");i[E]=!0,n++}}if(n!==t)throw Error('Block "'+this.type+'": Message does not reference all '+t+" arg(s).")}interpolateArguments_(e,t,i){const n=[];for(let u=0;u=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 i=this.inputList[e];this.inputList.splice(e,1),e{n.push(this.componentData.get(u))}),n.sort(function(u,E){return u.weight-E.weight}),n.forEach(function(u){i.push(u.component)})}else e.forEach(n=>{i.push(this.componentData.get(n).component)});return i}};Et.Capability=Wi;var Qg="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.",Kt=class{constructor(e){this.activeCandidate=this.lastMarker=this.lastOnStack=null,this.wouldDeleteBlock=!1,this.fadedBlock=this.highlightedBlock=this.markerConnection=null,I(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){Q(),this.hidePreview(),ie();var{local:e,closest:t}=this.activeCandidate;if(e.connect(t),this.topBlock.rendered){const i=e.isSuperior()?t:e,n=this.topBlock.getRootBlock();requestAnimationFrame(()=>{Aa(i.getSourceBlock()),setTimeout(()=>{n.bringToFront()},0)})}}}update(e,t){const i=this.getCandidate(e);((this.wouldDeleteBlock=this.shouldDelete(!!i,t))||this.shouldUpdatePreviews(i,e))&&(Q(),this.maybeHidePreview(i),this.maybeShowPreview(i),ie())}createMarkerBlock(e){var t=e.type;Q();let i;try{if(i=this.workspace.newBlock(t),i.setInsertionMarker(!0),e.saveExtraState){var n=e.saveExtraState();n&&i.loadExtraState&&i.loadExtraState(n)}else if(e.mutationToDom){const u=e.mutationToDom();u&&i.domToMutation&&i.domToMutation(u)}for(t=0;t"u"?"":t,this.oldValue=typeof i>"u"?"":i,this.newValue=typeof n>"u"?"":n}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}};m(pe.EVENT,sr,Bg);var Cn=class extends cs{constructor(e,t,i,n,u){super(e),this.type=$t,e&&(this.element=t,this.name=i||void 0,this.oldValue=n,this.newValue=u)}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){p("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,i){return t=super.fromJson(e,t,i??new Cn),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 i=Cn.getExtraBlockState_(t);t.loadExtraState?t.loadExtraState(JSON.parse(e||"{}")):t.domToMutation&&t.domToMutation(De(e||"")),k(new Cn(t,"mutation",null,i,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())?wi(e):""}};m(pe.EVENT,$t,Cn);var Jc=class extends cs{constructor(e){if(super(e),this.type=Ri,e){if(e.getParent())throw Error("Connected blocks cannot be deleted.");e.isShadow()&&(this.recordUndo=!1),this.oldXml=Fs(e),this.ids=he(e),this.wasShadow=e.isShadow(),this.oldJson=Si(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=wi(this.oldXml),e.ids=this.ids,e.wasShadow=this.wasShadow,e.oldJson=this.oldJson,this.recordUndo||(e.recordUndo=this.recordUndo),e}fromJson(e){p("Blockly.Events.BlockDelete.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.oldXml=De(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,i){return t=super.fromJson(e,t,i??new Jc),t.oldXml=De(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;eu.top?ta(i,n,u,b):t+b.heightdocument.documentElement.clientTop?ta(i,n,u,b):$d(e,u,b)}},ut={};ut.ANIMATION_TIME=jo,ut.ARROW_HORIZONTAL_PADDING=Pg,ut.ARROW_SIZE=fr,ut.BORDER_SIZE=Qc,ut.PADDING_Y=qc,ut.TEST_ONLY=ih,ut.clearContent=so,ut.createDom=Yl,ut.getContentDiv=Xn,ut.getOwner=jl,ut.getPositionX=Us,ut.hide=oo,ut.hideIfOwner=Yn,ut.hideWithoutAnimation=oi,ut.isVisible=ia,ut.repositionForWindowResize=vd,ut.setBoundsElement=Kl,ut.setColour=ro,ut.show=ql,ut.showPositionedByBlock=_d,ut.showPositionedByField=Gs;var mr=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,i;i=e[t];t++)this.unregisterMarker(i);this.markers.clear(),this.cursor_&&(this.cursor_.dispose(),this.cursor_=null)}};mr.LOCAL_MARKER="local_marker_1",s.module$build$src$core$utils$string={},s.module$build$src$core$utils$string.commonWordPrefix=sa,s.module$build$src$core$utils$string.commonWordSuffix=ra,s.module$build$src$core$utils$string.isNumber=aa,s.module$build$src$core$utils$string.shortestStringLength=Hs,s.module$build$src$core$utils$string.startsWith=Td,s.module$build$src$core$utils$string.wrap=oa;var Jo=void 0,_r=!1,gs=!1,Gg=50,Ug=0,On=0,nh=0,sh=0,ii=null,$r=null,rh=0,oh=10,Hg=10,Vg=750,Zo=5,gt=null,dt={};dt.HOVER_MS=Vg,dt.LIMIT=Gg,dt.MARGINS=Zo,dt.OFFSET_X=rh,dt.OFFSET_Y=oh,dt.RADIUS_OK=Hg,dt.bindMouseEvents=Vs,dt.block=ga,dt.createDom=ha,dt.dispose=pa,dt.getCustomTooltip=wd,dt.getDiv=Id,dt.getTooltipOfObject=Kn,dt.hide=en,dt.isVisible=Sd,dt.setCustomTooltip=yd,dt.unbindMouseEvents=ua,dt.unblock=fa;var lh=.45,ah=.65,Wg={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"},It={};It.blend=vn,It.getHsvSaturation=ma,It.getHsvValue=_a,It.hexToRgb=ao,It.hsvToHex=co,It.hueToHex=ho,It.names=Wg,It.parse=tn,It.rgbToHex=Ws,It.setHsvSaturation=Md,It.setHsvValue=Nd;var vr={};vr.checkMessageReferences=zs,vr.parseBlockColour=Tn,vr.replaceMessageReferences=rt,vr.tokenizeInterpolation=po;var Qo=null,qo=null,fs="",ms="",pi,gi={};gi.createDom=$a,gi.getDiv=En,gi.hide=li,gi.hideIfOwner=fo,gi.isVisible=va,gi.positionWithAnchor=Ea,gi.show=go,gi.testOnly_setDiv=Dd;var Pe=class{constructor(e,t,i){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 Tt(0,0),e!==Pe.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(e),t&&this.setValidator(t))}configure_(e){e.tooltip&&this.setTooltip(rt(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_=ee(q.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_=ee(q.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_=ee(q.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.");Vs(e),this.mouseDownWrapper_=ve(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(Pe),e!==null?e:this.getValue()}loadState(e){this.loadLegacyState(Pe,e)||this.setValue(e)}saveLegacyState(e){return e.prototype.saveState===this.saveState&&e.prototype.toXml!==this.toXml?(e=s.createElement$$module$build$src$core$utils$xml("field"),e.setAttribute("name",this.name||""),Ct(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(De(t)),!0):!1}dispose(){Yn(this),fo(this);let e;(e=this.getSourceBlock())!=null&&e.isDeadOrDying()||ue(this.fieldGroup_),this.disposed=!0}updateEditable(){const e=this.fieldGroup_,t=this.getSourceBlock();this.EDITABLE&&e&&t&&(this.enabled_&&t.isEditable()?(Te(e,"blocklyEditableText"),xe(e,"blocklyNonEditableText"),e.style.cursor=this.CURSOR):(Te(e,"blocklyNonEditableText"),xe(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_!==Pe.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 i=2*e,n=t.FIELD_TEXT_HEIGHT,u=0;this.textElement_&&(u=L(this.textElement_,t.FIELD_TEXT_FONTSIZE,t.FIELD_TEXT_FONTWEIGHT,t.FIELD_TEXT_FONTFAMILY),i+=u),this.borderRect_&&(n=Math.max(n,t.FIELD_BORDER_RECT_HEIGHT)),this.size_.height=n,this.size_.width=i,this.positionTextElement_(e,u),this.positionBorderRect_()}positionTextElement_(e,t){if(this.textElement_){var i=this.getConstants(),n=this.size_.height/2,u;this.textElement_.setAttribute("x",String((u=this.getSourceBlock())!=null&&u.RTL?this.size_.width-t-e:e)),this.textElement_.setAttribute("y",String(i.FIELD_TEXT_BASELINE_CENTER?n:n-i.FIELD_TEXT_HEIGHT/2+i.FIELD_TEXT_BASELINE))}}positionBorderRect_(){this.borderRect_&&(this.borderRect_.setAttribute("width",String(this.size_.width)),this.borderRect_.setAttribute("height",String(this.size_.height)),this.borderRect_.setAttribute("rx",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)),this.borderRect_.setAttribute("ry",String(this.getConstants().FIELD_BORDER_RECT_RADIUS)))}getSize(){return this.isVisible()?(this.isDirty_?(this.render_(),this.isDirty_=!1):this.visible_&&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 Tt(0,0)}getScaledBBox(){let e;var t=this.getSourceBlock();if(!t)throw new pt;if(this.borderRect_){var i=this.borderRect_.getBoundingClientRect();e=Zi(this.borderRect_),t=i.width,i=i.height}else{i=this.sourceBlock_.getHeightWidth();const n=t.workspace.scale;e=this.getAbsoluteXY_(),t=(i.width+1)*n,i=(i.height+1)*n,Hc?(e.x+=1.5*n,e.y+=1.5*n):(e.x-=.5*n,e.y-=.5*n)}return new ct(e.y,e.y+i,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,Pe.NBSP),this.sourceBlock_&&this.sourceBlock_.RTL&&(e+="‏"),e):Pe.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 i;t=(i=this.getValidator())==null?void 0:i.call(this,e),i=this.processValidation_(e,t),i instanceof Error||(e=this.sourceBlock_,e&&e.disposed||(t=this.getValue(),t===i?this.doValueUpdate_(i):(this.doValueUpdate_(i),e&&J()&&k(new(le($t))(e,"field",this.name||null,t,i)),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 Kn(e||{tooltip:this.tooltip_})}getClickTarget_(){return this.clickTarget_||this.getSvgRoot()}getAbsoluteXY_(){return Zi(this.getClickTarget_())}referencesVariables(){return!1}refreshVariableName(){}getParentInput(){let e=null;const t=this.getSourceBlock();if(!t)throw new pt;const i=t.inputList;for(let n=0;ne?this.menuItems.length:e,-1)}highlightFirst(){this.highlightHelper(-1,1)}highlightLast(){this.highlightHelper(this.menuItems.length,-1)}highlightHelper(e,t){e+=t;let i;for(;i=this.menuItems[e];){if(i.isEnabled()){this.setHighlighted(i);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 i=new ge(e.clientX,e.clientY);if(1>ge.distance(t,i))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=Bs(e);return t.height=e.scrollHeight,t}},uh=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=F(),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 i=document.createElement("div");i.className="blocklyMenuItemCheckbox goog-menuitem-checkbox",t.appendChild(i)}return i=this.content,typeof this.content=="string"&&(i=document.createTextNode(this.content)),t.appendChild(i),e.appendChild(t),this.roleName&&ai(e,this.roleName),st(e,it.SELECTED,this.checkable&&this.checked||!1),st(e,it.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?(Te(t,"blocklyMenuItemHighlight"),Te(t,"goog-menuitem-highlight")):(xe(t,"blocklyMenuItemHighlight"),xe(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)}},Oi=class extends Pe{constructor(e,t,i){super(Pe.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!==Pe.SKIP_SETUP&&(Array.isArray(e)?(ba(e),e=Gd(e),this.menuGenerator_=e.options,this.prefixField=e.prefix||null,this.suffixField=e.suffix||null):this.menuGenerator_=e,this.selectedOption_=this.getOptions(!1)[0],i&&this.configure_(i),this.setValue(this.selectedOption_[1]),t&&this.setValidator(t))}fromXml(e){this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e.textContent)}loadState(e){this.loadLegacyState(Oi,e)||(this.isOptionListDynamic()&&this.getOptions(!1),this.setValue(e))}initView(){this.shouldAddBorderRect_()?this.createBorderRect_():this.clickTarget_=this.sourceBlock_.getSvgRoot(),this.createTextElement_(),this.imageElement_=ee(q.IMAGE,{},this.fieldGroup_),this.getConstants().FIELD_DROPDOWN_SVG_ARROW?this.createSVGArrow_():this.createTextArrow_(),this.borderRect_&&Te(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_=ee(q.TSPAN,{},this.textElement_);let e;this.arrow_.appendChild(document.createTextNode((e=this.getSourceBlock())!=null&&e.RTL?Oi.ARROW_CHAR+" ":" "+Oi.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_=ee(q.IMAGE,{height:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px",width:this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE+"px"},this.fieldGroup_),this.svgArrow_.setAttributeNS(Ht,"xlink:href",this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI)}showEditor_(e){var t=this.getSourceBlock();if(!t)throw new pt;this.dropdownCreate_(),this.menu_.openingCoords=e&&typeof e.clientX=="number"?new ge(e.clientX,e.clientY):null,so(),e=this.menu_.render(Xn()),Te(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,ro(e,t)),Gs(this,this.dropdownDispose_.bind(this)),this.menu_.focus(),this.selectedMenuItem_&&(this.menu_.setHighlighted(this.selectedMenuItem_),Qr(this.selectedMenuItem_.getElement(),Xn(),!0)),this.applyColour()}dropdownCreate_(){const e=this.getSourceBlock();if(!e)throw new pt;const t=new hh;t.setRole(Wt.LISTBOX),this.menu_=t;const i=this.getOptions(!1);this.selectedMenuItem_=null;for(let u=0;ut[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,i;i=e[t];t++)i[1]===this.value_&&(this.selectedOption_=i)}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 pt;this.imageElement_.style.display="",this.imageElement_.setAttributeNS(Ht,"xlink:href",e.src),this.imageElement_.setAttribute("height",String(e.height)),this.imageElement_.setAttribute("width",String(e.width));const i=Number(e.height);e=Number(e.width);var n=!!this.borderRect_;const u=Math.max(n?this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT:0,i+Km);n=n?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0;let b;b=this.svgArrow_?this.positionSVGArrow_(e+n,u/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2):L(this.arrow_,this.getConstants().FIELD_TEXT_FONTSIZE,this.getConstants().FIELD_TEXT_FONTWEIGHT,this.getConstants().FIELD_TEXT_FONTFAMILY),this.size_.width=e+b+2*n,this.size_.height=u;let G=0;t.RTL?this.imageElement_.setAttribute("x",`${n+b}`):(G=e+b,this.getTextElement().setAttribute("text-anchor","end"),this.imageElement_.setAttribute("x",`${n}`)),this.imageElement_.setAttribute("y",String(u/2-i/2)),this.positionTextElement_(G+n,e+b)}renderSelectedText_(){this.getTextContent().nodeValue=this.getDisplayText_();var e=this.getTextElement();Te(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 i=L(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 n=0;this.svgArrow_&&(n=this.positionSVGArrow_(i+t,e/2-this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE/2)),this.size_.width=i+n+2*t,this.size_.height=e,this.positionTextElement_(t,i)}positionSVGArrow_(e,t){if(!this.svgArrow_)return 0;const i=this.getSourceBlock();if(!i)throw new pt;const n=this.borderRect_?this.getConstants().FIELD_BORDER_RECT_X_PADDING:0,u=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING,b=this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;return this.svgArrow_.setAttribute("transform","translate("+(i.RTL?n:e+u)+","+t+")"),b+u}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)}};Oi.CHECKMARK_OVERHANG=25,Oi.MAX_MENU_HEIGHT_VH=.45,Oi.ARROW_CHAR="▾";var Ym=5,Km=2*Ym;Yt("field_dropdown",Oi);var dh=class extends di{constructor(e,t,i){super(e?e.workspace.id:void 0),this.type=Gi,e&&(this.blockId=e.id,this.isOpen=t,this.bubbleType=i)}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){p("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,i){return t=super.fromJson(e,t,i??new dh),t.isOpen=e.isOpen,t.bubbleType=e.bubbleType,t.blockId=e.blockId,t}},ph;(function(e){e.MUTATOR="mutator",e.COMMENT="comment",e.WARNING="warning"})(ph||(ph={})),m(pe.EVENT,Gi,dh);var ot=class{constructor(e,t,i,n,u){this.workspace=e,this.horizontal=t,this.oldHostMetrics=null,this.ratio=1,this.origin=new ge(0,0),this.startDragHandle=this.handlePosition=this.handleLength=this.scrollbarLength=this.startDragMouse=0,this.containerVisible=this.isHandleVisible=!0,this.position=new ge(0,0),this.onMouseMoveWrapper_=this.onMouseUpWrapper_=null,this.pair=i||!1,this.margin=u!==void 0?u:ot.DEFAULT_SCROLLBAR_MARGIN,e="blocklyScrollbar"+(this.horizontal?"Horizontal":"Vertical"),n&&(e+=" "+n),this.outerSvg=ee(q.SVG,{class:e}),n=ee(q.G,{},this.outerSvg),this.svgBackground=ee(q.RECT,{class:"blocklyScrollbarBackground"},n),e=Math.floor((ot.scrollbarThickness-5)/2),this.svgHandle=ee(q.RECT,{class:"blocklyScrollbarHandle",rx:e,ry:e},n),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarColour","fill"),this.workspace.getThemeManager().subscribe(this.svgHandle,"scrollbarOpacity","fill-opacity"),be(this.outerSvg,this.workspace.getParentSvg()),this.setInitialThickness(),t?(this.lengthAttribute_="width",this.positionAttribute_="x"):(this.lengthAttribute_="height",this.positionAttribute_="y"),this.onMouseDownBarWrapper_=ve(this.svgBackground,"pointerdown",this,this.onMouseDownBar),this.onMouseDownHandleWrapper_=ve(this.svgHandle,"pointerdown",this,this.onMouseDownHandle)}setInitialThickness(){const e=ot.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(),Je(this.onMouseDownBarWrapper_),Je(this.onMouseDownHandleWrapper_),ue(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,Be(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&&ot.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-=ot.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),t=e.absoluteLeft+this.margin,this.pair&&this.workspace.RTL&&(t+=ot.scrollbarThickness),this.setPosition(t,e.absoluteTop+e.viewHeight-ot.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 i=this.scrollbarLength-this.handleLength;e=(e.viewLeft-e.scrollLeft)/t*i,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=i/t}}resizeVertical(e){this.requiresViewResize(e)?this.resizeViewVertical(e):this.resizeContentVertical(e)}resizeViewVertical(e){let t=e.viewHeight-2*this.margin;this.pair&&(t-=ot.scrollbarThickness),this.setScrollbarLength(Math.max(0,t)),this.setPosition(this.workspace.RTL?e.absoluteLeft+this.margin:e.absoluteLeft+e.viewWidth-ot.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 i=this.scrollbarLength-this.handleLength;e=(e.viewTop-e.scrollTop)/t*i,e=this.constrainHandlePosition(e),this.setHandlePosition(e),this.ratio=i/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(),bi(),this.cleanUp(),Bi(e))e.stopPropagation();else{var t=_n(e,this.workspace.getParentSvg(),this.workspace.getInverseScreenCTM());t=this.horizontal?t.x:t.y;var i=Ps(this.svgHandle);i=this.horizontal?i.x:i.y;var n=this.handlePosition,u=.95*this.handleLength;t<=i?n-=u:t>=i+this.handleLength&&(n+=u),this.setHandlePosition(this.constrainHandlePosition(n)),this.updateMetrics(),e.stopPropagation(),e.preventDefault()}}onMouseDownHandle(e){this.workspace.markFocused(),this.cleanUp(),Bi(e)?e.stopPropagation():(this.startDragHandle=this.handlePosition,this.workspace.setupDragSurface(),this.startDragMouse=this.horizontal?e.clientX:e.clientY,this.onMouseUpWrapper_=ve(document,"pointerup",this,this.onMouseUpHandle),this.onMouseMoveWrapper_=ve(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(),bi(),this.cleanUp()}cleanUp(){this.workspace.hideChaff(!0),this.onMouseUpWrapper_&&(Je(this.onMouseUpWrapper_),this.onMouseUpWrapper_=null),this.onMouseMoveWrapper_&&(Je(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 ge(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}};ot.scrollbarThickness=fg?25:15,ot.DEFAULT_SCROLLBAR_MARGIN=.5;var Ae=class{constructor(e,t,i,n,u,b){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_=i,i=Ae.ARROW_ANGLE,this.workspace_.RTL&&(i=-i),this.arrowRadians=Wn(i),e.getBubbleCanvas().appendChild(this.createDom(t,!(!u||!b))),this.setAnchorLocation(n),u&&b||(e=this.content_.getBBox(),u=e.width+2*Ae.BORDER_WIDTH,b=e.height+2*Ae.BORDER_WIDTH),this.setBubbleSize(u,b),this.positionBubble(),this.renderArrow(),this.rendered=!0}createDom(e,t){this.bubbleGroup=ee(q.G,{});var i={filter:"url(#"+this.workspace_.getRenderer().getConstants().embossFilterId+")"};return bg&&(i={}),i=ee(q.G,i,this.bubbleGroup),this.bubbleArrow=ee(q.PATH,{},i),this.bubbleBack=ee(q.RECT,{class:"blocklyDraggable",x:0,y:0,rx:Ae.BORDER_WIDTH,ry:Ae.BORDER_WIDTH},i),t?(this.resizeGroup=ee(q.G,{class:this.workspace_.RTL?"blocklyResizeSW":"blocklyResizeSE"},this.bubbleGroup),t=2*Ae.BORDER_WIDTH,ee(q.POLYGON,{points:`0,${t} ${t},${t} ${t},0`},this.resizeGroup),ee(q.LINE,{class:"blocklyResizeLine",x1:t/3,y1:t-1,x2:t-1,y2:t/3},this.resizeGroup),ee(q.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=ve(this.bubbleBack,"pointerdown",this,this.bubbleMouseDown),this.resizeGroup&&(this.onMouseDownResizeWrapper=ve(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(),Ae.unbindDragEvents(),Bi(e)||(this.workspace_.startDrag(e,new ge(this.workspace_.RTL?-this.width:this.width,this.height)),Ae.onMouseUpWrapper=ve(document,"pointerup",this,Ae.bubbleMouseUp),Ae.onMouseMoveWrapper=ve(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),i=this.getOptimalRelativeTop(e),n=this.shape_.getBBox();const u={x:t,y:-this.height-this.workspace_.getRenderer().getConstants().MIN_BLOCK_HEIGHT},b={x:-this.width-30,y:i};i={x:n.width,y:i};var G={x:t,y:n.height};t=n.widthe.width)return t;if(this.workspace_.RTL){var i=this.anchorXY.x-t,n=e.left+e.width;e=e.left+ot.scrollbarThickness/this.workspace_.scale,i-this.widthn&&(t=-(n-this.anchorXY.x))}else{i=t+this.anchorXY.x,n=i+this.width;const u=e.left;e=e.left+e.width-ot.scrollbarThickness/this.workspace_.scale,ie&&(t=e-this.anchorXY.x-this.width)}return t}getOptimalRelativeTop(e){let t=-this.height/4;if(this.height>e.height)return t;const i=this.anchorXY.y+t,n=i+this.height,u=e.top;e=e.top+e.height-ot.scrollbarThickness/this.workspace_.scale;const b=this.anchorXY.y;return ie&&(t=e-b-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 i;(i=this.bubbleGroup)==null||i.setAttribute("transform","translate("+e+","+t+")")}setDragging(e){!e&&this.moveCallback&&this.moveCallback()}getBubbleSize(){return new Tt(this.width,this.height)}setBubbleSize(e,t){const i=2*Ae.BORDER_WIDTH;e=Math.max(e,i+45),t=Math.max(t,i+20),this.width=e,this.height=t;let n;(n=this.bubbleBack)==null||n.setAttribute("width",`${e}`);let u;(u=this.bubbleBack)==null||u.setAttribute("height",`${t}`),this.resizeGroup&&(this.workspace_.RTL?this.resizeGroup.setAttribute("transform","translate("+2*Ae.BORDER_WIDTH+","+(t-i)+") scale(-1 1)"):this.resizeGroup.setAttribute("transform","translate("+(e-i)+","+(t-i)+")")),this.autoLayout&&this.layoutBubble(),this.positionBubble(),this.renderArrow(),this.resizeCallback&&this.resizeCallback()}renderArrow(){const e=[];var t=this.width/2,i=this.height/2,n=-this.relativeLeft,u=-this.relativeTop;if(t===n&&i===u)e.push("M "+t+","+i);else{u-=i,n-=t,this.workspace_.RTL&&(n*=-1);var b=Math.sqrt(u*u+n*n),G=Math.acos(n/b);0>u&&(G=2*Math.PI-G);var X=G+Math.PI/2;X>2*Math.PI&&(X-=2*Math.PI);var re=Math.sin(X);const at=Math.cos(X);var me=this.getBubbleSize();X=(me.width+me.height)/Ae.ARROW_THICKNESS,X=Math.min(X,me.width,me.height)/4,me=1-Ae.ANCHOR_RADIUS/b,n=t+me*n,u=i+me*u,me=t+X*at;const zt=i+X*re;t-=X*at,i-=X*re,re=G+this.arrowRadians,re>2*Math.PI&&(re-=2*Math.PI),G=Math.sin(re)*b/Ae.ARROW_BEND,b=Math.cos(re)*b/Ae.ARROW_BEND,e.push("M"+me+","+zt),e.push("C"+(me+b)+","+(zt+G)+" "+n+","+u+" "+n+","+u),e.push("C"+n+","+u+" "+(t+b)+","+(i+G)+" "+t+","+i)}e.push("z");let lt;(lt=this.bubbleArrow)==null||lt.setAttribute("d",e.join(" "))}setColour(e){let t;(t=this.bubbleBack)==null||t.setAttribute("fill",e);let i;(i=this.bubbleArrow)==null||i.setAttribute("fill",e)}dispose(){this.onMouseDownBubbleWrapper&&Je(this.onMouseDownBubbleWrapper),this.onMouseDownResizeWrapper&&Je(this.onMouseDownResizeWrapper),Ae.unbindDragEvents(),ue(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 ge(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(){Ae.onMouseUpWrapper&&(Je(Ae.onMouseUpWrapper),Ae.onMouseUpWrapper=null),Ae.onMouseMoveWrapper&&(Je(Ae.onMouseMoveWrapper),Ae.onMouseMoveWrapper=null)}static bubbleMouseUp(e){bi(),Ae.unbindDragEvents()}static textToDom(e){const t=ee(q.TEXT,{class:"blocklyText blocklyBubbleText blocklyNoPointerEvents",y:Ae.BORDER_WIDTH});e=e.split(` +`);for(let i=0;ie||Math.abs(this.workspaceHeight-u)>e)&&(this.workspaceWidth=n,this.workspaceHeight=u,this.bubble_.setBubbleSize(n+e,u+e),this.svgDialog.setAttribute("width",`${n}`),this.svgDialog.setAttribute("height",`${u}`),this.workspace_.setCachedParentSvgSize(n,u)),b&&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 Ae(t.workspace,this.createEditor(),t.pathObject.svgPath,this.iconXY_,null,null);var i=this.workspace_;this.bubble_.setSvgId(t.id),this.bubble_.registerMoveEvent(this.onBubbleMove.bind(this));var n=i.options.languageTree;const u=i.getFlyout();n&&(u.init(i),u.show(n)),this.rootBlock=t.decompose(i),n=this.rootBlock.getDescendants(!1);for(let G=0,X;X=n[G];G++)X.render();this.rootBlock.setMovable(!1),this.rootBlock.setDeletable(!1);let b;if(u?(n=2*u.CORNER_RADIUS,b=this.rootBlock.RTL?u.getWidth()+n:n):b=n=16,t.RTL&&(b=-b),this.rootBlock.moveBy(b,n),t.saveConnections){const G=this.rootBlock;t.saveConnections(G),this.sourceListener=()=>{const X=this.getBlock();X.saveConnections&&X.saveConnections(G)},t.workspace.addChangeListener(this.sourceListener)}this.resizeBubble(),n=this.workspaceChanged.bind(this),i.addChangeListener(n),u&&u.getWorkspace().addChangeListener(n),this.updateWorkspace(),this.applyColour()}else this.svgDialog=null,this.workspace_.dispose(),this.rootBlock=this.workspace_=null,(i=this.bubble_)==null||i.dispose(),this.bubble_=null,this.workspaceHeight=this.workspaceWidth=0,this.sourceListener&&(t.workspace.removeChangeListener(this.sourceListener),this.sourceListener=null);k(new(le(Gi))(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===wt||e.type===$t&&e.element==="disabled"}updateWorkspace(){if(!this.workspace_.isDragging()){var e=this.workspace_.getTopBlocks(!1);for(let n=0,u;u=e[n];n++){var t=u.getRelativeToSurfaceXY();if(20>t.y&&u.moveBy(0,20-t.y),u.RTL){var i=-20;const b=this.workspace_.getFlyout();b&&(i-=b.getWidth()),t.x>i&&u.moveBy(i-t.x,0)}else 20>t.x&&u.moveBy(20-t.x,0)}}if(this.rootBlock&&this.rootBlock.workspace===this.workspace_){(e=Y())||z(!0);const n=this.getBlock();if(t=Cn.getExtraBlockState_(n),n.compose(this.rootBlock),i=Cn.getExtraBlockState_(n),t!==i){k(new(le($t))(n,"mutation",null,t,i));const u=Y();setTimeout(function(){const b=Y();z(u),n.bumpNeighbours(),z(b)},s.config$$module$build$src$core$config.bumpDelay)}this.workspace_.isDragging()||setTimeout(()=>this.resizeBubble(),0),z(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 i=0,n;n=t[i];i++)n.setStyle(n.getStyleName());if(e=e.getFlyout()){e=e.getWorkspace().getAllBlocks(!1);for(let i=0,n;n=e[i];i++)n.setStyle(n.getStyleName())}}}static reconnect(e,t,i){if(!e||!e.getSourceBlock().workspace)return!1;i=t.getInput(i).connection;const n=e.targetBlock();return n&&n!==t||!i||i.targetConnection===e?!1:(i.isConnected()&&i.disconnect(),i.connect(e),!0)}static findParentWs(e){let t=null;if(e&&e.options){const i=e.options.parentWorkspace;e.isFlyout?i&&i.options&&(t=i.options.parentWorkspace):i&&(t=i)}return t}},Kg={},Kg.Mutator=s.Mutator$$module$build$src$core$mutator;var _s=Object.create(null),Zm={allExtensions:_s};s.register$$module$build$src$core$extensions("parent_tooltip_when_inline",tp),s.module$build$src$core$extensions={},s.module$build$src$core$extensions.TEST_ONLY=Zm,s.module$build$src$core$extensions.apply=To,s.module$build$src$core$extensions.buildTooltipForDropdown=s.buildTooltipForDropdown$$module$build$src$core$extensions,s.module$build$src$core$extensions.buildTooltipWithFieldText=s.buildTooltipWithFieldText$$module$build$src$core$extensions,s.module$build$src$core$extensions.isRegistered=Sa,s.module$build$src$core$extensions.register=s.register$$module$build$src$core$extensions,s.module$build$src$core$extensions.registerMixin=Kd,s.module$build$src$core$extensions.registerMutator=s.registerMutator$$module$build$src$core$extensions,s.module$build$src$core$extensions.runAfterPageLoad=Ks,s.module$build$src$core$extensions.unregister=jd;var hn=class extends Pe{constructor(e,t,i){super(Pe.SKIP_SETUP),this.class_=null,this.EDITABLE=!1,e!==Pe.SKIP_SETUP&&(i?this.configure_(i):this.class_=t||null,this.setValue(e))}configure_(e){super.configure_(e),e.class&&(this.class_=e.class)}initView(){this.createTextElement_(),this.class_&&Te(this.getTextElement(),this.class_)}doClassValidation_(e){return e==null?null:`${e}`}setClass(e){this.textElement_&&(this.class_&&xe(this.textElement_,this.class_),e&&Te(this.textElement_,e)),this.class_=e}static fromJson(e){return new this(rt(e.text),void 0,e)}};Yt("field_label",hn),hn.prototype.DEFAULT_VALUE="";var $s=class{constructor(e,t,i,n){if(this.type=e,this.name=t,this.connection=n,this.fieldRow=[],this.align=s.Align$$module$build$src$core$input.LEFT,this.visible=!0,e!==ke.DUMMY&&!t)throw Error("Value inputs and statement inputs must have non-empty name.");this.sourceBlock=i}getSourceBlock(){return this.sourceBlock}appendField(e,t){return this.insertFieldAt(this.fieldRow.length,e,t),this}insertFieldAt(e,t,i){if(0>e||e>this.fieldRow.length)throw Error("index "+e+" out of bounds.");return(t||t===""&&i)&&(typeof t=="string"&&(t=mo({type:"field_label",text:t})),t.setSourceBlock(this.sourceBlock),this.sourceBlock.rendered&&(t.init(),t.applyColour()),t.name=i,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 i=0,n;n=this.fieldRow[i];i++)if(n.name===e)return n.dispose(),this.fieldRow.splice(i,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 n=0,u;u=this.fieldRow[n];n++)u.setVisible(e);if(this.connection){var i=this.connection;e?t=i.startTrackingAll():i.stopTrackingAll(),(i=i.targetBlock())&&(i.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;ee.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 i=0,n;n=t.fieldRow[i];i++)n.initModel&&n.initModel()}unplug(e){this.outputConnection&&this.unplugFromRow_(e),this.previousConnection&&this.unplugFromStack_(e)}unplugFromRow_(e){let t=null,i;(i=this.outputConnection)!=null&&i.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(n=n+(i==="("||u===")"?"":" ")+u,i=u[u.length-1],n),""),t=t.trim()||"???",e&&t.length>e&&(t=t.substring(0,e-3)+"..."),t}toTokens(e="?"){const t=[];for(const n of this.inputList)if(n.name!=hs){for(const u of n.fieldRow)t.push(u.getText());if(n.connection){const u=n.connection.targetBlock();if(u){var i=n.connection;let b=i.getCheck();!b&&i.targetConnection&&(b=i.targetConnection.getCheck()),(i=!!b&&(b.indexOf("Boolean")!==-1||b.indexOf("Number")!==-1))&&t.push("("),t.push(...u.toTokens(e)),i&&t.push(")")}else t.push(e)}}return t}appendValueInput(e){return this.appendInput_(ke.VALUE,e)}appendStatementInput(e){return this.appendInput_(ke.STATEMENT,e)}appendDummyInput(e){return this.appendInput_(ke.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 i=0;e["message"+i]!==void 0;)this.interpolate_(e["message"+i],e["args"+i]||[],e["lastDummyAlign"+i],t),i++;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&&(i=rt(e.tooltip),this.setTooltip(i)),e.enableContextMenu!==void 0&&(this.contextMenu=!!e.enableContextMenu),e.suppressPrefixSuffix!==void 0&&(this.suppressPrefixSuffix=!!e.suppressPrefixSuffix),e.helpUrl!==void 0&&(i=rt(e.helpUrl),this.setHelpUrl(i)),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&&To(e.mutator,this,!0),e=e.extensions,Array.isArray(e))for(t=0;tb||b>t)throw Error('Block "'+this.type+'": Message index %'+b+" out of range.");if(i[b])throw Error('Block "'+this.type+'": Message index %'+b+" duplicated.");i[b]=!0,n++}}if(n!==t)throw Error('Block "'+this.type+'": Message does not reference all '+t+" arg(s).")}interpolateArguments_(e,t,i){const n=[];for(let u=0;u=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 i=this.inputList[e];this.inputList.splice(e,1),e{n.push(this.componentData.get(u))}),n.sort(function(u,b){return u.weight-b.weight}),n.forEach(function(u){i.push(u.component)})}else e.forEach(n=>{i.push(this.componentData.get(n).component)});return i}};Et.Capability=Wi;var Zg="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.",jt=class{constructor(e){this.activeCandidate=this.lastMarker=this.lastOnStack=null,this.wouldDeleteBlock=!1,this.fadedBlock=this.highlightedBlock=this.markerConnection=null,y(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){Q(),this.hidePreview(),ie();var{local:e,closest:t}=this.activeCandidate;if(e.connect(t),this.topBlock.rendered){const i=e.isSuperior()?t:e,n=this.topBlock.getRootBlock();requestAnimationFrame(()=>{ka(i.getSourceBlock()),setTimeout(()=>{n.bringToFront()},0)})}}}update(e,t){const i=this.getCandidate(e);((this.wouldDeleteBlock=this.shouldDelete(!!i,t))||this.shouldUpdatePreviews(i,e))&&(Q(),this.maybeHidePreview(i),this.maybeShowPreview(i),ie())}createMarkerBlock(e){var t=e.type;Q();let i;try{if(i=this.workspace.newBlock(t),i.setInsertionMarker(!0),e.saveExtraState){var n=e.saveExtraState();n&&i.loadExtraState&&i.loadExtraState(n)}else if(e.mutationToDom){const u=e.mutationToDom();u&&i.domToMutation&&i.domToMutation(u)}for(t=0;tclearTimeout(e)),this.warningTextDb.clear(),this.getIcons().forEach(e=>e.dispose()))}checkAndDelete(){this.workspace.isFlyout||(z(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),z(!1))}toCopyData(){return this.isInsertionMarker_?null:{saveInfo:Si(this,{addCoordinates:!0,addNextBlocks:!1}),source:this.workspace,typeCounts:N(this,!0)}}applyColour(){this.pathObject.applyColour(this);const e=this.getIcons();for(let t=0;t{this.isDeadOrDying()||(this.warningTextDb.delete(i),this.setWarningText(e,i))},100));else{if(this.isInFlyout&&(e=null),t=!1,typeof e=="string"){n=this.getSurroundParent();let u=null;for(;n;)n.isCollapsed()&&(u=n),n=n.getSurroundParent();u&&u.setWarningText(Ie.COLLAPSED_WARNINGS_WARNING,ii.COLLAPSED_WARNING_ID),this.warning||(this.warning=new of(this),t=!0),this.warning.setText(e,i)}else this.warning&&!i?(this.warning.dispose(),t=!0):this.warning&&(t=this.warning.getText(),this.warning.setText("",i),(n=this.warning.getText())||this.warning.dispose(),t=t!==n);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(),i=t.parentNode,n=i.childNodes;n[n.length-1]!==t&&i.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{const t=Y();z(e),this.getRootBlock().bumpNeighboursInternal(),z(t),this.bumpNeighboursPid=0},r.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 i;(i=t.targetBlock())==null||i.bumpNeighboursInternal()}for(const i of t.neighbours(r.config$$module$build$src$core$config.snapRadius))i.getSourceBlock().getRootBlock()!==e&&(t.isConnected()&&i.isConnected()||(t.isSuperior()?i.bumpAwayFrom(t):t.bumpAwayFrom(i)))}}scheduleSnapAndBump(){const e=Y();setTimeout(()=>{z(e),this.snapToGrid(),z(!1)},r.config$$module$build$src$core$config.bumpDelay/2),this.bumpNeighbours()}positionNearConnection(e,t){e.type!==$e.NEXT_STATEMENT&&e.type!==$e.INPUT_VALUE||this.moveBy(t.x-e.x,t.y-e.y)}getFirstStatementConnection(){return super.getFirstStatementConnection()}getChildren(e){return super.getChildren(e)}queueRender(){gp(this)}render(e){if(!this.renderIsInProgress_){this.renderIsInProgress_=!0;try{if(this.rendered=!0,He(),this.isCollapsed()&&this.updateCollapsed_(),this.workspace.getRenderer().render(this),this.updateConnectionLocations(),e!==!1){const t=this.getParent();t?t.render(!0):this.workspace.resizeContents()}Qe(),this.updateMarkers_()}finally{this.renderIsInProgress_=!1}}}renderEfficiently(){this.rendered=!0,He(),this.isCollapsed()&&this.updateCollapsed_(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),Qe(),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(mr.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;ti||t.getSourceBlock().isInsertionMarker())return!1;switch(t.type){case $e.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(e,t);case $e.OUTPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isInsertionMarker()||e.isConnected())return!1;break;case $e.INPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;case $e.NEXT_STATEMENT:if(t.isConnected()&&!e.getSourceBlock().nextConnection&&!t.targetBlock().isShadow()&&t.targetBlock().nextConnection||t.targetBlock()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;default:return!1}return En.indexOf(t)===-1}canConnectToPrevious_(e,t){return e.targetConnection||En.indexOf(t)!==-1?!1:t.targetConnection?(e=t.targetBlock(),e.isInsertionMarker()?!e.getPreviousBlock():!1):!0}};m(pe.CONNECTION_CHECKER,Fi,af);var vs=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 i=this.calculateIndexForYPos_(t);if(i>=this.connections_.length)return-1;t=e.y;let n=i;for(;0<=n&&this.connections_[n].y===t;){if(this.connections_[n]===e)return n;n--}for(n=i;ne)i=n;else{t=n;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 i(me){const lt=u-n[me].x,at=E-n[me].y;return Math.sqrt(lt*lt+at*at)<=t&&re.push(n[me]),at"u"?"":t,this.newContents_=typeof i>"u"?"":i)}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){p("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,i){return t=super.fromJson(e,t,i??new Ch),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 i=e?this.newContents_:this.oldContents_;if(!i)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(i)}else console.warn("Can't change non-existent comment: "+this.commentId)}};m(pe.EVENT,cr,Ch);var kh=class extends un{constructor(e){super(e),this.type=wn,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=wi(this.xml),e}fromJson(e){p("Blockly.Events.CommentCreate.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.xml=De(e.xml)}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new kh),t.xml=De(e.xml),t}run(e){un.CommentCreateDeleteHelper(this,e)}};m(pe.EVENT,wn,kh);var Ah=class extends un{constructor(e){super(e),this.type=ts,e&&(this.xml=e.toXmlWithXY())}run(e){un.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=wi(this.xml),e}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new Ah),t.xml=De(e.xml),t}};m(pe.EVENT,ts,Ah);var Oh=class extends un{constructor(e){super(e),this.type=Ui,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){p("Blockly.Events.CommentMove.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e);let t=e.oldCoordinate.split(",");this.oldCoordinate_=new ge(Number(t[0]),Number(t[1])),t=e.newCoordinate.split(","),this.newCoordinate_=new ge(Number(t[0]),Number(t[1]))}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new Oh),i=e.oldCoordinate.split(","),t.oldCoordinate_=new ge(Number(i[0]),Number(i[1])),i=e.newCoordinate.split(","),t.newCoordinate_=new ge(Number(i[0]),Number(i[1])),t}isNull(){return ge.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 i=t.getRelativeToSurfaceXY();t.moveBy(e.x-i.x,e.y-i.y)}else console.warn("Can't move non-existent comment: "+this.commentId)}};m(pe.EVENT,Ui,Oh);var Lh=class extends di{constructor(e,t,i,n){let u=e?e.workspace.id:void 0;n&&n.getType()===ce.types.WORKSPACE&&(u=n.getLocation().id),super(u),this.type=rr,this.blockId=e==null?void 0:e.id,this.oldNode=i||void 0,this.newNode=n,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){p("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,i){return t=super.fromJson(e,t,i??new Lh),t.isCursor=e.isCursor,t.blockId=e.blockId,t.oldNode=e.oldNode,t.newNode=e.newNode,t}};m(pe.EVENT,rr,Lh);var Mh=class extends di{constructor(e,t){super(t),this.type=ar,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){p("Blockly.Events.ThemeChange.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.themeName=e.themeName}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new Mh),t.themeName=e.themeName,t}};m(pe.EVENT,ar,Mh);var Nh=class extends di{constructor(e,t,i){super(i),this.type=lr,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){p("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,i){return t=super.fromJson(e,t,i??new Nh),t.oldItem=e.oldItem,t.newItem=e.newItem,t}};m(pe.EVENT,lr,Nh);var Dh=class extends di{constructor(e,t){super(t),this.type=or,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){p("Blockly.Events.TrashcanOpen.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.isOpen=e.isOpen}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new Dh),t.isOpen=e.isOpen,t}};m(pe.EVENT,or,Dh);var xh=class extends hr{constructor(e){super(e),this.type=qn,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){p("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,i){return t=super.fromJson(e,t,i??new xh),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)}};m(pe.EVENT,qn,xh);var Bh=class extends hr{constructor(e,t){super(e),this.type=nr,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){p("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,i){return t=super.fromJson(e,t,i??new Bh),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)}};m(pe.EVENT,nr,Bh);var Ph=class extends di{constructor(e,t,i,n,u){super(n),this.type=yn,this.viewTop=e,this.viewLeft=t,this.scale=i,this.oldScale=u}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){p("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,i){return t=super.fromJson(e,t,i??new Ph),t.viewTop=e.viewTop,t.viewLeft=e.viewLeft,t.scale=e.scale,t.oldScale=e.oldScale,t}};m(pe.EVENT,yn,Ph),r.module$build$src$core$events$events={},r.module$build$src$core$events$events.Abstract=rs,r.module$build$src$core$events$events.BLOCK_CHANGE=$t,r.module$build$src$core$events$events.BLOCK_CREATE=wt,r.module$build$src$core$events$events.BLOCK_DELETE=Ri,r.module$build$src$core$events$events.BLOCK_DRAG=es,r.module$build$src$core$events$events.BLOCK_MOVE=Ot,r.module$build$src$core$events$events.BUBBLE_OPEN=Gi,r.module$build$src$core$events$events.BUMP_EVENTS=Lc,r.module$build$src$core$events$events.BlockBase=as,r.module$build$src$core$events$events.BlockChange=Rn,r.module$build$src$core$events$events.BlockCreate=jc,r.module$build$src$core$events$events.BlockDelete=Jc,r.module$build$src$core$events$events.BlockDrag=_h,r.module$build$src$core$events$events.BlockMove=Sh,r.module$build$src$core$events$events.BubbleOpen=dh,r.module$build$src$core$events$events.BubbleType=ph,r.module$build$src$core$events$events.CHANGE=$t,r.module$build$src$core$events$events.CLICK=on,r.module$build$src$core$events$events.COMMENT_CHANGE=cr,r.module$build$src$core$events$events.COMMENT_CREATE=wn,r.module$build$src$core$events$events.COMMENT_DELETE=ts,r.module$build$src$core$events$events.COMMENT_MOVE=Ui,r.module$build$src$core$events$events.CREATE=wt,r.module$build$src$core$events$events.Click=Ih,r.module$build$src$core$events$events.ClickTarget=Rh,r.module$build$src$core$events$events.CommentBase=un,r.module$build$src$core$events$events.CommentChange=Ch,r.module$build$src$core$events$events.CommentCreate=kh,r.module$build$src$core$events$events.CommentDelete=Ah,r.module$build$src$core$events$events.CommentMove=Oh,r.module$build$src$core$events$events.DELETE=Ri,r.module$build$src$core$events$events.FINISHED_LOADING=is,r.module$build$src$core$events$events.FinishedLoading=Bg,r.module$build$src$core$events$events.MARKER_MOVE=rr,r.module$build$src$core$events$events.MOVE=Ot,r.module$build$src$core$events$events.MarkerMove=Lh,r.module$build$src$core$events$events.SELECTED=rn,r.module$build$src$core$events$events.Selected=Fc,r.module$build$src$core$events$events.THEME_CHANGE=ar,r.module$build$src$core$events$events.TOOLBOX_ITEM_SELECT=lr,r.module$build$src$core$events$events.TRASHCAN_OPEN=or,r.module$build$src$core$events$events.ThemeChange=Mh,r.module$build$src$core$events$events.ToolboxItemSelect=Nh,r.module$build$src$core$events$events.TrashcanOpen=Dh,r.module$build$src$core$events$events.UI=sr,r.module$build$src$core$events$events.Ui=Pg,r.module$build$src$core$events$events.UiBase=di,r.module$build$src$core$events$events.VAR_CREATE=bn,r.module$build$src$core$events$events.VAR_DELETE=qn,r.module$build$src$core$events$events.VAR_RENAME=nr,r.module$build$src$core$events$events.VIEWPORT_CHANGE=yn,r.module$build$src$core$events$events.VarBase=hr,r.module$build$src$core$events$events.VarCreate=Bc,r.module$build$src$core$events$events.VarDelete=xh,r.module$build$src$core$events$events.VarRename=Bh,r.module$build$src$core$events$events.ViewportChange=Ph,r.module$build$src$core$events$events.clearPendingUndo=K,r.module$build$src$core$events$events.disable=Q,r.module$build$src$core$events$events.disableOrphans=Re,r.module$build$src$core$events$events.enable=ie,r.module$build$src$core$events$events.filter=W,r.module$build$src$core$events$events.fire=O,r.module$build$src$core$events$events.fromJson=de,r.module$build$src$core$events$events.get=le,r.module$build$src$core$events$events.getDescendantIds=he,r.module$build$src$core$events$events.getGroup=Y,r.module$build$src$core$events$events.getRecordUndo=L,r.module$build$src$core$events$events.isEnabled=J,r.module$build$src$core$events$events.setGroup=z,r.module$build$src$core$events$events.setRecordUndo=T,sc();var Mt={};Mt.registerCleanup=za,Mt.registerCollapse=Ya,Mt.registerCollapseExpandBlock=ec,Mt.registerComment=Qa,Mt.registerDefaultOptions=sc,Mt.registerDelete=ic,Mt.registerDeleteAll=Ja,Mt.registerDisable=tc,Mt.registerDuplicate=Za,Mt.registerExpand=Ka,Mt.registerHelp=nc,Mt.registerInline=qa,Mt.registerRedo=Wa,Mt.registerUndo=Va;var cf=class{constructor(){}onDragEnter(e){}onDragOver(e){}onDragExit(e){}onDrop(e){}getClientRect(){return null}shouldPreventMove(e){return!1}},rl=class extends cf{constructor(){super(),this.wouldDelete_=!1}wouldDelete(e,t){return e instanceof ii?(e=!e.getParent()&&e.isDeletable(),this.updateWouldDelete_(e&&!t)):this.updateWouldDelete_(e.isDeletable()),this.wouldDelete_}updateWouldDelete_(e){this.wouldDelete_=e}},kr=class extends Pe{constructor(e,t,i){super(Pe.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!==Pe.SKIP_SETUP&&(i&&this.configure_(i),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 pt;if(this.getConstants().FULL_BLOCK_FIELDS){let t=0,i=0;for(let n=0,u;u=e.inputList[n];n++){for(let E=0;u.fieldRow[E];E++)t++;u.connection&&i++}this.fullBlockClickTarget_=1>=t&&e.outputConnection&&!i}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_&&J()&&O(new(le($t))(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_?(xe(e,"blocklyInvalidInput"),st(e,it.INVALID,!1)):(Te(e,"blocklyInvalidInput"),st(e,it.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&&(Wc||Wo||os)?this.showPromptEditor_():this.showInlineEditor_(t)}showPromptEditor_(){Xr(Ie.CHANGE_VALUE_TITLE,this.getText(),e=>{e!==null&&this.setValue(this.getValueFromEditorText_(e))})}showInlineEditor_(e){const t=this.getSourceBlock();if(!t)throw new pt;go(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 pt;z(!0);const t=Tn();var i=this.getClickTarget_();if(!i)throw Error("A click target has not been set.");Te(i,"editing"),i=document.createElement("input"),i.className="blocklyHtmlInput",i.setAttribute("spellcheck",this.spellcheck_);const n=this.workspace_.getScale();var u=this.getConstants().FIELD_TEXT_FONTSIZE*n+"pt";return t.style.fontSize=u,i.style.fontSize=u,u=kr.BORDERRADIUS*n+"px",this.fullBlockClickTarget_&&(u=this.getScaledBBox(),u=(u.bottom-u.top)/2+"px",e=e.getParent()?e.getParent().style.colourTertiary:this.sourceBlock_.style.colourTertiary,i.style.border=1*n+"px solid "+e,t.style.borderRadius=u,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*n+"px")),i.style.borderRadius=u,t.appendChild(i),i.value=i.defaultValue=this.getEditorText_(this.value_),i.setAttribute("data-untyped-default-value",String(this.value_)),this.resizeEditor_(),this.bindInputEvents_(i),i}widgetDispose_(){this.isBeingEdited_=!1,this.isTextValid_=!0,this.forceRerender(),this.onFinishEditing_(this.value_),z(!1),this.unbindInputEvents_();var e=Tn().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.");xe(e,"editing")}onFinishEditing_(e){}bindInputEvents_(e){this.onKeyDownWrapper_=ve(e,"keydown",this,this.onHtmlInputKeyDown_),this.onKeyInputWrapper_=ve(e,"input",this,this.onHtmlInputChange_)}unbindInputEvents_(){this.onKeyDownWrapper_&&(je(this.onKeyDownWrapper_),this.onKeyDownWrapper_=null),this.onKeyInputWrapper_&&(je(this.onKeyInputWrapper_),this.onKeyInputWrapper_=null)}onHtmlInputKeyDown_(e){e.key==="Enter"?(li(),oi()):e.key==="Escape"?(this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value")),li(),oi()):e.key==="Tab"&&(li(),oi(),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 pt;const t=Tn(),i=this.getScaledBBox();t.style.width=i.right-i.left+"px",t.style.height=i.bottom-i.top+"px",e=new ge(e.RTL?i.right-t.offsetWidth:i.left,i.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}};kr.BORDERRADIUS=4;var Le=class extends kr{constructor(e,t,i){super(Pe.SKIP_SETUP),this.clockwise=Le.CLOCKWISE,this.offset=Le.OFFSET,this.wrap=Le.WRAP,this.round=Le.ROUND,this.boundEvents=[],this.symbol_=this.gauge=this.line=null,e!==Pe.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(e),t&&this.setValidator(t))}configure_(e){switch(super.configure_(e),e.mode){case ol.COMPASS:this.clockwise=!0,this.offset=90;break;case ol.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_=ee(q.TSPAN,{}),this.symbol_.appendChild(document.createTextNode("°")),this.getTextElement().appendChild(this.symbol_)}render_(){super.render_(),this.updateGraph()}showEditor_(e){super.showEditor_(e,Wc||Wo||os),e=this.dropdownCreate(),zn().appendChild(e),this.sourceBlock_ instanceof ii&&ro(this.sourceBlock_.style.colourPrimary,this.sourceBlock_.style.colourTertiary),Gs(this,this.dropdownDispose.bind(this)),this.updateGraph()}dropdownCreate(){const e=ee(q.SVG,{xmlns:ss,"xmlns:html":hi,"xmlns:xlink":Ht,version:"1.1",height:2*Le.HALF+"px",width:2*Le.HALF+"px",style:"touch-action: none"}),t=ee(q.CIRCLE,{cx:Le.HALF,cy:Le.HALF,r:Le.RADIUS,class:"blocklyAngleCircle"},e);this.gauge=ee(q.PATH,{class:"blocklyAngleGauge"},e),this.line=ee(q.LINE,{x1:Le.HALF,y1:Le.HALF,class:"blocklyAngleLine"},e);for(let i=0;360>i;i+=15)ee(q.LINE,{x1:Le.HALF+Le.RADIUS,y1:Le.HALF,x2:Le.HALF+Le.RADIUS-(i%45===0?10:5),y2:Le.HALF,class:"blocklyAngleMarks",transform:"rotate("+i+","+Le.HALF+","+Le.HALF+")"},e);return this.boundEvents.push(ve(e,"click",this,this.hide)),this.boundEvents.push(ve(t,"pointerdown",this,this.onMouseMove_,!0)),this.boundEvents.push(ve(t,"pointermove",this,this.onMouseMove_,!0)),e}dropdownDispose(){for(const e of this.boundEvents)je(e);this.boundEvents.length=0,this.line=this.gauge=null}hide(){Xn(this),li()}onMouseMove_(e){var t=this.gauge.ownerSVGElement.getBoundingClientRect();const i=e.clientX-t.left-Le.HALF;e=e.clientY-t.top-Le.HALF,t=Math.atan(-e/i),isNaN(t)||(t=Xl(t),0>i?t+=180:0e&&(e+=360),e>this.wrap&&(e-=360),e}static fromJson(e){return new this(e.angle,void 0,e)}};Le.HALF=50,Le.RADIUS=Le.HALF-1,Le.CLOCKWISE=!1,Le.OFFSET=0,Le.WRAP=360,Le.ROUND=15,Xt("field_angle",Le),Le.prototype.DEFAULT_VALUE=0,qt(` +`);var zi=null,$h={duplicateInternal:rp,copyInternal:sp},Sr={};Sr.TEST_ONLY=$h,Sr.copy=Jn,Sr.duplicate=Js,Sr.paste=wo;var Ir,vh,Rr;Ir=null,vh={},Rr=null,s.module$build$src$core$contextmenu={},s.module$build$src$core$contextmenu.callbackFactory=up,s.module$build$src$core$contextmenu.commentDeleteOption=Ba,s.module$build$src$core$contextmenu.commentDuplicateOption=Pa,s.module$build$src$core$contextmenu.dispose=xa,s.module$build$src$core$contextmenu.getCurrentBlock=op,s.module$build$src$core$contextmenu.hide=Qs,s.module$build$src$core$contextmenu.setCurrentBlock=Da,s.module$build$src$core$contextmenu.show=Zs,s.module$build$src$core$contextmenu.workspaceCommentOption=dp;var Ye=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 i=[];for(const u of this.registry_.values())if(e===u.scopeType){var n=u.preconditionFn(t);n!=="hidden"&&(n={text:typeof u.displayText=="function"?u.displayText(t):u.displayText,enabled:n==="enabled",callback:u.callback,scope:t,weight:u.weight},i.push(n))}return i.sort(function(u,b){return u.weight-b.weight}),i}};(function(e){var t=e.ScopeType||(e.ScopeType={});t.BLOCK="block",t.WORKSPACE="workspace",e.registry=new e})(Ye||(Ye={})),Ye.ScopeType;var ef=30,tf=!0,Mn=[];Mn[$e.INPUT_VALUE]=$e.OUTPUT_VALUE,Mn[$e.OUTPUT_VALUE]=$e.INPUT_VALUE,Mn[$e.NEXT_STATEMENT]=$e.PREVIOUS_STATEMENT,Mn[$e.PREVIOUS_STATEMENT]=$e.NEXT_STATEMENT;var Th="RENAME_VARIABLE_ID",Eh="DELETE_VARIABLE_ID",ce=class{constructor(e,t,i){if(this.wsCoordinate_=null,!t)throw Error("Cannot create a node without a location.");this.type_=e,this.isConnection_=ce.isConnectionType_(e),this.location_=t,this.processParams_(i||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;eclearTimeout(e)),this.warningTextDb.clear(),this.getIcons().forEach(e=>e.dispose()))}checkAndDelete(){this.workspace.isFlyout||(z(!0),this.workspace.hideChaff(),this.outputConnection?this.dispose(!1,!0):this.dispose(!0,!0),z(!1))}toCopyData(){return this.isInsertionMarker_?null:{saveInfo:Si(this,{addCoordinates:!0,addNextBlocks:!1}),source:this.workspace,typeCounts:N(this,!0)}}applyColour(){this.pathObject.applyColour(this);const e=this.getIcons();for(let t=0;t{this.isDeadOrDying()||(this.warningTextDb.delete(i),this.setWarningText(e,i))},100));else{if(this.isInFlyout&&(e=null),t=!1,typeof e=="string"){n=this.getSurroundParent();let u=null;for(;n;)n.isCollapsed()&&(u=n),n=n.getSurroundParent();u&&u.setWarningText(Ie.COLLAPSED_WARNINGS_WARNING,ni.COLLAPSED_WARNING_ID),this.warning||(this.warning=new rf(this),t=!0),this.warning.setText(e,i)}else this.warning&&!i?(this.warning.dispose(),t=!0):this.warning&&(t=this.warning.getText(),this.warning.setText("",i),(n=this.warning.getText())||this.warning.dispose(),t=t!==n);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(),i=t.parentNode,n=i.childNodes;n[n.length-1]!==t&&i.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{const t=Y();z(e),this.getRootBlock().bumpNeighboursInternal(),z(t),this.bumpNeighboursPid=0},s.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 i;(i=t.targetBlock())==null||i.bumpNeighboursInternal()}for(const i of t.neighbours(s.config$$module$build$src$core$config.snapRadius))i.getSourceBlock().getRootBlock()!==e&&(t.isConnected()&&i.isConnected()||(t.isSuperior()?i.bumpAwayFrom(t):t.bumpAwayFrom(i)))}}scheduleSnapAndBump(){const e=Y();setTimeout(()=>{z(e),this.snapToGrid(),z(!1)},s.config$$module$build$src$core$config.bumpDelay/2),this.bumpNeighbours()}positionNearConnection(e,t){e.type!==$e.NEXT_STATEMENT&&e.type!==$e.INPUT_VALUE||this.moveBy(t.x-e.x,t.y-e.y)}getFirstStatementConnection(){return super.getFirstStatementConnection()}getChildren(e){return super.getChildren(e)}queueRender(){pp(this)}render(e){if(!this.renderIsInProgress_){this.renderIsInProgress_=!0;try{if(this.rendered=!0,Ve(),this.isCollapsed()&&this.updateCollapsed_(),this.workspace.getRenderer().render(this),this.updateConnectionLocations(),e!==!1){const t=this.getParent();t?t.render(!0):this.workspace.resizeContents()}Qe(),this.updateMarkers_()}finally{this.renderIsInProgress_=!1}}}renderEfficiently(){this.rendered=!0,Ve(),this.isCollapsed()&&this.updateCollapsed_(),this.workspace.getRenderer().render(this),this.tightenChildrenEfficiently(),Qe(),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(mr.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;ti||t.getSourceBlock().isInsertionMarker())return!1;switch(t.type){case $e.PREVIOUS_STATEMENT:return this.canConnectToPrevious_(e,t);case $e.OUTPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isInsertionMarker()||e.isConnected())return!1;break;case $e.INPUT_VALUE:if(t.isConnected()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;case $e.NEXT_STATEMENT:if(t.isConnected()&&!e.getSourceBlock().nextConnection&&!t.targetBlock().isShadow()&&t.targetBlock().nextConnection||t.targetBlock()&&!t.targetBlock().isMovable()&&!t.targetBlock().isShadow())return!1;break;default:return!1}return bn.indexOf(t)===-1}canConnectToPrevious_(e,t){return e.targetConnection||bn.indexOf(t)!==-1?!1:t.targetConnection?(e=t.targetBlock(),e.isInsertionMarker()?!e.getPreviousBlock():!1):!0}};m(pe.CONNECTION_CHECKER,Fi,lf);var Ts=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 i=this.calculateIndexForYPos_(t);if(i>=this.connections_.length)return-1;t=e.y;let n=i;for(;0<=n&&this.connections_[n].y===t;){if(this.connections_[n]===e)return n;n--}for(n=i;ne)i=n;else{t=n;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 i(me){const lt=u-n[me].x,at=b-n[me].y;return Math.sqrt(lt*lt+at*at)<=t&&re.push(n[me]),at"u"?"":t,this.newContents_=typeof i>"u"?"":i)}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){p("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,i){return t=super.fromJson(e,t,i??new Ch),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 i=e?this.newContents_:this.oldContents_;if(!i)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(i)}else console.warn("Can't change non-existent comment: "+this.commentId)}};m(pe.EVENT,cr,Ch);var Ah=class extends un{constructor(e){super(e),this.type=Sn,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=wi(this.xml),e}fromJson(e){p("Blockly.Events.CommentCreate.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.xml=De(e.xml)}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new Ah),t.xml=De(e.xml),t}run(e){un.CommentCreateDeleteHelper(this,e)}};m(pe.EVENT,Sn,Ah);var kh=class extends un{constructor(e){super(e),this.type=is,e&&(this.xml=e.toXmlWithXY())}run(e){un.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=wi(this.xml),e}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new kh),t.xml=De(e.xml),t}};m(pe.EVENT,is,kh);var Oh=class extends un{constructor(e){super(e),this.type=Ui,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){p("Blockly.Events.CommentMove.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e);let t=e.oldCoordinate.split(",");this.oldCoordinate_=new ge(Number(t[0]),Number(t[1])),t=e.newCoordinate.split(","),this.newCoordinate_=new ge(Number(t[0]),Number(t[1]))}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new Oh),i=e.oldCoordinate.split(","),t.oldCoordinate_=new ge(Number(i[0]),Number(i[1])),i=e.newCoordinate.split(","),t.newCoordinate_=new ge(Number(i[0]),Number(i[1])),t}isNull(){return ge.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 i=t.getRelativeToSurfaceXY();t.moveBy(e.x-i.x,e.y-i.y)}else console.warn("Can't move non-existent comment: "+this.commentId)}};m(pe.EVENT,Ui,Oh);var Lh=class extends di{constructor(e,t,i,n){let u=e?e.workspace.id:void 0;n&&n.getType()===ce.types.WORKSPACE&&(u=n.getLocation().id),super(u),this.type=rr,this.blockId=e==null?void 0:e.id,this.oldNode=i||void 0,this.newNode=n,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){p("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,i){return t=super.fromJson(e,t,i??new Lh),t.isCursor=e.isCursor,t.blockId=e.blockId,t.oldNode=e.oldNode,t.newNode=e.newNode,t}};m(pe.EVENT,rr,Lh);var Mh=class extends di{constructor(e,t){super(t),this.type=ar,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){p("Blockly.Events.ThemeChange.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.themeName=e.themeName}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new Mh),t.themeName=e.themeName,t}};m(pe.EVENT,ar,Mh);var Nh=class extends di{constructor(e,t,i){super(i),this.type=lr,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){p("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,i){return t=super.fromJson(e,t,i??new Nh),t.oldItem=e.oldItem,t.newItem=e.newItem,t}};m(pe.EVENT,lr,Nh);var Dh=class extends di{constructor(e,t){super(t),this.type=or,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){p("Blockly.Events.TrashcanOpen.prototype.fromJson","version 9","version 10","Blockly.Events.fromJson"),super.fromJson(e),this.isOpen=e.isOpen}static fromJson(e,t,i){return t=super.fromJson(e,t,i??new Dh),t.isOpen=e.isOpen,t}};m(pe.EVENT,or,Dh);var xh=class extends hr{constructor(e){super(e),this.type=es,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){p("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,i){return t=super.fromJson(e,t,i??new xh),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)}};m(pe.EVENT,es,xh);var Bh=class extends hr{constructor(e,t){super(e),this.type=nr,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){p("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,i){return t=super.fromJson(e,t,i??new Bh),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)}};m(pe.EVENT,nr,Bh);var Ph=class extends di{constructor(e,t,i,n,u){super(n),this.type=wn,this.viewTop=e,this.viewLeft=t,this.scale=i,this.oldScale=u}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){p("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,i){return t=super.fromJson(e,t,i??new Ph),t.viewTop=e.viewTop,t.viewLeft=e.viewLeft,t.scale=e.scale,t.oldScale=e.oldScale,t}};m(pe.EVENT,wn,Ph),s.module$build$src$core$events$events={},s.module$build$src$core$events$events.Abstract=os,s.module$build$src$core$events$events.BLOCK_CHANGE=$t,s.module$build$src$core$events$events.BLOCK_CREATE=wt,s.module$build$src$core$events$events.BLOCK_DELETE=Ri,s.module$build$src$core$events$events.BLOCK_DRAG=ts,s.module$build$src$core$events$events.BLOCK_MOVE=Ot,s.module$build$src$core$events$events.BUBBLE_OPEN=Gi,s.module$build$src$core$events$events.BUMP_EVENTS=Lc,s.module$build$src$core$events$events.BlockBase=cs,s.module$build$src$core$events$events.BlockChange=Cn,s.module$build$src$core$events$events.BlockCreate=jc,s.module$build$src$core$events$events.BlockDelete=Jc,s.module$build$src$core$events$events.BlockDrag=_h,s.module$build$src$core$events$events.BlockMove=Sh,s.module$build$src$core$events$events.BubbleOpen=dh,s.module$build$src$core$events$events.BubbleType=ph,s.module$build$src$core$events$events.CHANGE=$t,s.module$build$src$core$events$events.CLICK=on,s.module$build$src$core$events$events.COMMENT_CHANGE=cr,s.module$build$src$core$events$events.COMMENT_CREATE=Sn,s.module$build$src$core$events$events.COMMENT_DELETE=is,s.module$build$src$core$events$events.COMMENT_MOVE=Ui,s.module$build$src$core$events$events.CREATE=wt,s.module$build$src$core$events$events.Click=Ih,s.module$build$src$core$events$events.ClickTarget=Rh,s.module$build$src$core$events$events.CommentBase=un,s.module$build$src$core$events$events.CommentChange=Ch,s.module$build$src$core$events$events.CommentCreate=Ah,s.module$build$src$core$events$events.CommentDelete=kh,s.module$build$src$core$events$events.CommentMove=Oh,s.module$build$src$core$events$events.DELETE=Ri,s.module$build$src$core$events$events.FINISHED_LOADING=ns,s.module$build$src$core$events$events.FinishedLoading=xg,s.module$build$src$core$events$events.MARKER_MOVE=rr,s.module$build$src$core$events$events.MOVE=Ot,s.module$build$src$core$events$events.MarkerMove=Lh,s.module$build$src$core$events$events.SELECTED=rn,s.module$build$src$core$events$events.Selected=Fc,s.module$build$src$core$events$events.THEME_CHANGE=ar,s.module$build$src$core$events$events.TOOLBOX_ITEM_SELECT=lr,s.module$build$src$core$events$events.TRASHCAN_OPEN=or,s.module$build$src$core$events$events.ThemeChange=Mh,s.module$build$src$core$events$events.ToolboxItemSelect=Nh,s.module$build$src$core$events$events.TrashcanOpen=Dh,s.module$build$src$core$events$events.UI=sr,s.module$build$src$core$events$events.Ui=Bg,s.module$build$src$core$events$events.UiBase=di,s.module$build$src$core$events$events.VAR_CREATE=yn,s.module$build$src$core$events$events.VAR_DELETE=es,s.module$build$src$core$events$events.VAR_RENAME=nr,s.module$build$src$core$events$events.VIEWPORT_CHANGE=wn,s.module$build$src$core$events$events.VarBase=hr,s.module$build$src$core$events$events.VarCreate=Bc,s.module$build$src$core$events$events.VarDelete=xh,s.module$build$src$core$events$events.VarRename=Bh,s.module$build$src$core$events$events.ViewportChange=Ph,s.module$build$src$core$events$events.clearPendingUndo=K,s.module$build$src$core$events$events.disable=Q,s.module$build$src$core$events$events.disableOrphans=Re,s.module$build$src$core$events$events.enable=ie,s.module$build$src$core$events$events.filter=W,s.module$build$src$core$events$events.fire=k,s.module$build$src$core$events$events.fromJson=de,s.module$build$src$core$events$events.get=le,s.module$build$src$core$events$events.getDescendantIds=he,s.module$build$src$core$events$events.getGroup=Y,s.module$build$src$core$events$events.getRecordUndo=O,s.module$build$src$core$events$events.isEnabled=J,s.module$build$src$core$events$events.setGroup=z,s.module$build$src$core$events$events.setRecordUndo=E,sc();var Mt={};Mt.registerCleanup=za,Mt.registerCollapse=Ya,Mt.registerCollapseExpandBlock=ec,Mt.registerComment=Qa,Mt.registerDefaultOptions=sc,Mt.registerDelete=ic,Mt.registerDeleteAll=Ja,Mt.registerDisable=tc,Mt.registerDuplicate=Za,Mt.registerExpand=Ka,Mt.registerHelp=nc,Mt.registerInline=qa,Mt.registerRedo=Wa,Mt.registerUndo=Va;var af=class{constructor(){}onDragEnter(e){}onDragOver(e){}onDragExit(e){}onDrop(e){}getClientRect(){return null}shouldPreventMove(e){return!1}},rl=class extends af{constructor(){super(),this.wouldDelete_=!1}wouldDelete(e,t){return e instanceof ni?(e=!e.getParent()&&e.isDeletable(),this.updateWouldDelete_(e&&!t)):this.updateWouldDelete_(e.isDeletable()),this.wouldDelete_}updateWouldDelete_(e){this.wouldDelete_=e}},Ar=class extends Pe{constructor(e,t,i){super(Pe.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!==Pe.SKIP_SETUP&&(i&&this.configure_(i),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 pt;if(this.getConstants().FULL_BLOCK_FIELDS){let t=0,i=0;for(let n=0,u;u=e.inputList[n];n++){for(let b=0;u.fieldRow[b];b++)t++;u.connection&&i++}this.fullBlockClickTarget_=1>=t&&e.outputConnection&&!i}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_&&J()&&k(new(le($t))(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_?(xe(e,"blocklyInvalidInput"),st(e,it.INVALID,!1)):(Te(e,"blocklyInvalidInput"),st(e,it.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&&(Wc||Wo||ls)?this.showPromptEditor_():this.showInlineEditor_(t)}showPromptEditor_(){Xr(Ie.CHANGE_VALUE_TITLE,this.getText(),e=>{e!==null&&this.setValue(this.getValueFromEditorText_(e))})}showInlineEditor_(e){const t=this.getSourceBlock();if(!t)throw new pt;go(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 pt;z(!0);const t=En();var i=this.getClickTarget_();if(!i)throw Error("A click target has not been set.");Te(i,"editing"),i=document.createElement("input"),i.className="blocklyHtmlInput",i.setAttribute("spellcheck",this.spellcheck_);const n=this.workspace_.getScale();var u=this.getConstants().FIELD_TEXT_FONTSIZE*n+"pt";return t.style.fontSize=u,i.style.fontSize=u,u=Ar.BORDERRADIUS*n+"px",this.fullBlockClickTarget_&&(u=this.getScaledBBox(),u=(u.bottom-u.top)/2+"px",e=e.getParent()?e.getParent().style.colourTertiary:this.sourceBlock_.style.colourTertiary,i.style.border=1*n+"px solid "+e,t.style.borderRadius=u,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*n+"px")),i.style.borderRadius=u,t.appendChild(i),i.value=i.defaultValue=this.getEditorText_(this.value_),i.setAttribute("data-untyped-default-value",String(this.value_)),this.resizeEditor_(),this.bindInputEvents_(i),i}widgetDispose_(){this.isBeingEdited_=!1,this.isTextValid_=!0,this.forceRerender(),this.onFinishEditing_(this.value_),z(!1),this.unbindInputEvents_();var e=En().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.");xe(e,"editing")}onFinishEditing_(e){}bindInputEvents_(e){this.onKeyDownWrapper_=ve(e,"keydown",this,this.onHtmlInputKeyDown_),this.onKeyInputWrapper_=ve(e,"input",this,this.onHtmlInputChange_)}unbindInputEvents_(){this.onKeyDownWrapper_&&(Je(this.onKeyDownWrapper_),this.onKeyDownWrapper_=null),this.onKeyInputWrapper_&&(Je(this.onKeyInputWrapper_),this.onKeyInputWrapper_=null)}onHtmlInputKeyDown_(e){e.key==="Enter"?(li(),oi()):e.key==="Escape"?(this.setValue(this.htmlInput_.getAttribute("data-untyped-default-value")),li(),oi()):e.key==="Tab"&&(li(),oi(),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 pt;const t=En(),i=this.getScaledBBox();t.style.width=i.right-i.left+"px",t.style.height=i.bottom-i.top+"px",e=new ge(e.RTL?i.right-t.offsetWidth:i.left,i.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}};Ar.BORDERRADIUS=4;var Le=class extends Ar{constructor(e,t,i){super(Pe.SKIP_SETUP),this.clockwise=Le.CLOCKWISE,this.offset=Le.OFFSET,this.wrap=Le.WRAP,this.round=Le.ROUND,this.boundEvents=[],this.symbol_=this.gauge=this.line=null,e!==Pe.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(e),t&&this.setValidator(t))}configure_(e){switch(super.configure_(e),e.mode){case ol.COMPASS:this.clockwise=!0,this.offset=90;break;case ol.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_=ee(q.TSPAN,{}),this.symbol_.appendChild(document.createTextNode("°")),this.getTextElement().appendChild(this.symbol_)}render_(){super.render_(),this.updateGraph()}showEditor_(e){super.showEditor_(e,Wc||Wo||ls),e=this.dropdownCreate(),Xn().appendChild(e),this.sourceBlock_ instanceof ni&&ro(this.sourceBlock_.style.colourPrimary,this.sourceBlock_.style.colourTertiary),Gs(this,this.dropdownDispose.bind(this)),this.updateGraph()}dropdownCreate(){const e=ee(q.SVG,{xmlns:rs,"xmlns:html":hi,"xmlns:xlink":Ht,version:"1.1",height:2*Le.HALF+"px",width:2*Le.HALF+"px",style:"touch-action: none"}),t=ee(q.CIRCLE,{cx:Le.HALF,cy:Le.HALF,r:Le.RADIUS,class:"blocklyAngleCircle"},e);this.gauge=ee(q.PATH,{class:"blocklyAngleGauge"},e),this.line=ee(q.LINE,{x1:Le.HALF,y1:Le.HALF,class:"blocklyAngleLine"},e);for(let i=0;360>i;i+=15)ee(q.LINE,{x1:Le.HALF+Le.RADIUS,y1:Le.HALF,x2:Le.HALF+Le.RADIUS-(i%45===0?10:5),y2:Le.HALF,class:"blocklyAngleMarks",transform:"rotate("+i+","+Le.HALF+","+Le.HALF+")"},e);return this.boundEvents.push(ve(e,"click",this,this.hide)),this.boundEvents.push(ve(t,"pointerdown",this,this.onMouseMove_,!0)),this.boundEvents.push(ve(t,"pointermove",this,this.onMouseMove_,!0)),e}dropdownDispose(){for(const e of this.boundEvents)Je(e);this.boundEvents.length=0,this.line=this.gauge=null}hide(){Yn(this),li()}onMouseMove_(e){var t=this.gauge.ownerSVGElement.getBoundingClientRect();const i=e.clientX-t.left-Le.HALF;e=e.clientY-t.top-Le.HALF,t=Math.atan(-e/i),isNaN(t)||(t=Xl(t),0>i?t+=180:0e&&(e+=360),e>this.wrap&&(e-=360),e}static fromJson(e){return new this(e.angle,void 0,e)}};Le.HALF=50,Le.RADIUS=Le.HALF-1,Le.CLOCKWISE=!1,Le.OFFSET=0,Le.WRAP=360,Le.ROUND=15,Yt("field_angle",Le),Le.prototype.DEFAULT_VALUE=0,ei(` .blocklyAngleCircle { stroke: #444; stroke-width: 1; @@ -578,7 +578,7 @@ children`),this.state=e}},ls={};ls.BadConnectionCheck=Og,ls.DeserializationError stroke-linecap: round; pointer-events: none; } -`);var ol;(function(e){e.COMPASS="compass",e.PROTRACTOR="protractor"})(ol||(ol={}));var Mn=class extends Pe{constructor(e,t,i){super(Pe.SKIP_SETUP),this.SERIALIZABLE=!0,this.CURSOR="default",this.value_=this.value_,this.checkChar_=Mn.CHECK_CHAR,e!==Pe.SKIP_SETUP&&(i&&this.configure_(i),this.setValue(e),t&&this.setValidator(t))}configure_(e){super.configure_(e),e.checkCharacter&&(this.checkChar_=e.checkCharacter)}saveState(){const e=this.saveLegacyState(Mn);return e!==null?e:this.getValueBoolean()}initView(){super.initView();const e=this.getTextElement();Te(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||Mn.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)}};Mn.CHECK_CHAR="✓",Xt("field_checkbox",Mn),Mn.prototype.DEFAULT_VALUE=!1;var jt=class extends Pe{constructor(e,t,i){super(Pe.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!==Pe.SKIP_SETUP&&(i&&this.configure_(i),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 Tt(this.getConstants().FIELD_COLOUR_DEFAULT_WIDTH,this.getConstants().FIELD_COLOUR_DEFAULT_HEIGHT),this.getConstants().FIELD_COLOUR_FULL_BLOCK?this.sourceBlock_ instanceof ii&&(this.clickTarget_=this.sourceBlock_.getSvgRoot()):(this.createBorderRect_(),this.getBorderRect().style.fillOpacity="1")}applyColour(){this.getConstants().FIELD_COLOUR_FULL_BLOCK?this.sourceBlock_ instanceof ii&&(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:tn(e)}doValueUpdate_(e){this.value_=e,this.borderRect_?this.borderRect_.style.fill=e:this.sourceBlock_&&this.sourceBlock_.rendered&&this.sourceBlock_ instanceof ii&&(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(),zn().appendChild(this.picker),Gs(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),Xn(this))}onKeyDown(e){let t=!0;var i;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":(i=this.getHighlighted())&&(i=i.getAttribute("data-colour"),i!==null&&this.setValue(i)),oi();break;default:t=!1}t&&e.stopPropagation()}moveHighlightBy(e,t){if(this.highlightedIndex){var i=this.colours||jt.COLOURS,n=this.columns||jt.COLUMNS,u=this.highlightedIndex%n,E=Math.floor(this.highlightedIndex/n);u+=e,E+=t,0>e?0>u&&0u&&(u=0):0n-1&&En-1&&u--:0>t?0>E&&(E=0):0Math.floor(i.length/n)-1&&(E=Math.floor(i.length/n)-1),this.setHighlightedCell(this.picker.childNodes[E].childNodes[u],E*n+u)}}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())&&xe(e,"blocklyColourHighlighted")}getHighlighted(){if(!this.highlightedIndex)return null;const e=this.columns||jt.COLUMNS,t=this.picker.childNodes[Math.floor(this.highlightedIndex/e)];return t?t.childNodes[this.highlightedIndex%e]:null}setHighlightedCell(e,t){const i=this.getHighlighted();i&&xe(i,"blocklyColourHighlighted"),Te(e,"blocklyColourHighlighted"),this.highlightedIndex=t,(e=e.getAttribute("id"))&&this.picker&&st(this.picker,it.ACTIVEDESCENDANT,e)}dropdownCreate(){const e=this.columns||jt.COLUMNS,t=this.colours||jt.COLOURS,i=this.titles||jt.TITLES,n=this.getValue(),u=document.createElement("table");u.className="blocklyColourTable",u.tabIndex=0,u.dir="ltr",ai(u,Wt.GRID),st(u,it.EXPANDED,!0),st(u,it.ROWCOUNT,Math.floor(t.length/e)),st(u,it.COLCOUNT,e);let E;for(let G=0;Ge?0>u&&0u&&(u=0):0n-1&&bn-1&&u--:0>t?0>b&&(b=0):0Math.floor(i.length/n)-1&&(b=Math.floor(i.length/n)-1),this.setHighlightedCell(this.picker.childNodes[b].childNodes[u],b*n+u)}}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())&&xe(e,"blocklyColourHighlighted")}getHighlighted(){if(!this.highlightedIndex)return null;const e=this.columns||Jt.COLUMNS,t=this.picker.childNodes[Math.floor(this.highlightedIndex/e)];return t?t.childNodes[this.highlightedIndex%e]:null}setHighlightedCell(e,t){const i=this.getHighlighted();i&&xe(i,"blocklyColourHighlighted"),Te(e,"blocklyColourHighlighted"),this.highlightedIndex=t,(e=e.getAttribute("id"))&&this.picker&&st(this.picker,it.ACTIVEDESCENDANT,e)}dropdownCreate(){const e=this.columns||Jt.COLUMNS,t=this.colours||Jt.COLOURS,i=this.titles||Jt.TITLES,n=this.getValue(),u=document.createElement("table");u.className="blocklyColourTable",u.tabIndex=0,u.dir="ltr",ai(u,Wt.GRID),st(u,it.EXPANDED,!0),st(u,it.ROWCOUNT,Math.floor(t.length/e)),st(u,it.COLCOUNT,e);let b;for(let G=0;G=i||0>=t)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new Tt(t,i+Nn.Y_PADDING),this.imageHeight_=i,typeof u=="function"&&(this.clickHandler_=u),e!==Pe.SKIP_SETUP&&(G?this.configure_(G):(this.flipRtl_=!!E,this.altText_=rt(n)||""),this.setValue(rt(e)))}configure_(e){super.configure_(e),e.flipRtl&&(this.flipRtl_=e.flipRtl),e.alt&&(this.altText_=rt(e.alt))}initView(){this.imageElement_=ee(q.IMAGE,{height:this.imageHeight_+"px",width:this.size_.width+"px",alt:this.altText_},this.fieldGroup_),this.imageElement_.setAttributeNS(Ht,"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(Ht,"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)}};Nn.Y_PADDING=1,Xt("field_image",Nn),Nn.prototype.DEFAULT_VALUE="";var hf=class extends hn{constructor(e,t,i){super(String(e??""),t,i),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(e){return new this(rt(e.text),void 0,e)}};Xt("field_label_serializable",hf);var Ts=class extends kr{constructor(e,t,i){super(e,t,i)}doClassValidation_(e){return e===void 0?null:`${e}`}static fromJson(e){return new this(rt(e.text),void 0,e)}};Xt("field_input",Ts),Ts.prototype.DEFAULT_VALUE="";var Fh=class extends Ts{constructor(e,t,i){super(Pe.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,e!==Pe.SKIP_SETUP&&(i&&this.configure_(i),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,` +`);var Dn=class extends Pe{constructor(e,t,i,n,u,b,G){if(super(Pe.SKIP_SETUP),this.imageElement_=this.clickHandler_=null,this.flipRtl_=this.isDirty_=this.EDITABLE=!1,this.altText_="",i=Number(rt(i)),t=Number(rt(t)),isNaN(i)||isNaN(t))throw Error("Height and width values of an image field must cast to numbers.");if(0>=i||0>=t)throw Error("Height and width values of an image field must be greater than 0.");this.size_=new Tt(t,i+Dn.Y_PADDING),this.imageHeight_=i,typeof u=="function"&&(this.clickHandler_=u),e!==Pe.SKIP_SETUP&&(G?this.configure_(G):(this.flipRtl_=!!b,this.altText_=rt(n)||""),this.setValue(rt(e)))}configure_(e){super.configure_(e),e.flipRtl&&(this.flipRtl_=e.flipRtl),e.alt&&(this.altText_=rt(e.alt))}initView(){this.imageElement_=ee(q.IMAGE,{height:this.imageHeight_+"px",width:this.size_.width+"px",alt:this.altText_},this.fieldGroup_),this.imageElement_.setAttributeNS(Ht,"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(Ht,"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)}};Dn.Y_PADDING=1,Yt("field_image",Dn),Dn.prototype.DEFAULT_VALUE="";var cf=class extends hn{constructor(e,t,i){super(String(e??""),t,i),this.EDITABLE=!1,this.SERIALIZABLE=!0}static fromJson(e){return new this(rt(e.text),void 0,e)}};Yt("field_label_serializable",cf);var Es=class extends Ar{constructor(e,t,i){super(e,t,i)}doClassValidation_(e){return e===void 0?null:`${e}`}static fromJson(e){return new this(rt(e.text),void 0,e)}};Yt("field_input",Es),Es.prototype.DEFAULT_VALUE="";var Fh=class extends Es{constructor(e,t,i){super(Pe.SKIP_SETUP),this.textGroup=null,this.maxLines_=1/0,this.isOverflowedY_=!1,e!==Pe.SKIP_SETUP&&(i&&this.configure_(i),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,` `))}saveState(){const e=this.saveLegacyState(Fh);return e!==null?e:this.getValue()}loadState(e){this.loadLegacyState(Pe,e)||this.setValue(e)}initView(){this.createBorderRect_(),this.textGroup=ee(q.G,{class:"blocklyEditableText"},this.fieldGroup_)}getDisplayText_(){const e=this.getSourceBlock();if(!e)throw new pt;let t=this.getText();if(!t)return Pe.NBSP;const i=t.split(` -`);t="";const n=this.isOverflowedY_?this.maxLines_:i.length;for(let u=0;uthis.maxDisplayLength?E=E.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&u===n-1&&(E=E.substring(0,E.length-3)+"..."),E=E.replace(/\s/g,Pe.NBSP),t+=E,u!==n-1&&(t+=` +`);t="";const n=this.isOverflowedY_?this.maxLines_:i.length;for(let u=0;uthis.maxDisplayLength?b=b.substring(0,this.maxDisplayLength-4)+"...":this.isOverflowedY_&&u===n-1&&(b=b.substring(0,b.length-3)+"..."),b=b.replace(/\s/g,Pe.NBSP),t+=b,u!==n-1&&(t+=` `)}return e.RTL&&(t+="‏"),t}doValueUpdate_(e){super.doValueUpdate_(e),this.value_!==null&&(this.isOverflowedY_=this.value_.split(` `).length>this.maxLines_)}render_(){var e=this.getSourceBlock();if(!e)throw new pt;for(var t,i=this.textGroup;t=i.firstChild;)i.removeChild(t);t=this.getDisplayText_().split(` -`);let n=0;for(let u=0;uu&&(u=X),E+=this.getConstants().FIELD_TEXT_HEIGHT+(0this.maxDisplayLength&&(e[X]=e[X].substring(0,this.maxDisplayLength)),G.textContent=e[X];const re=M(G,t,i,n);re>u&&(u=re)}u+=this.htmlInput_.offsetWidth-this.htmlInput_.clientWidth}this.borderRect_&&(E+=2*this.getConstants().FIELD_BORDER_RECT_Y_PADDING,u+=2*this.getConstants().FIELD_BORDER_RECT_X_PADDING,this.borderRect_.setAttribute("width",`${u}`),this.borderRect_.setAttribute("height",`${E}`)),this.size_.width=u,this.size_.height=E,this.positionBorderRect_()}showEditor_(e,t){super.showEditor_(e,t),this.forceRerender()}widgetCreate_(){const e=Tn(),t=this.workspace_.getScale(),i=document.createElement("textarea");i.className="blocklyHtmlInput blocklyHtmlTextAreaInput",i.setAttribute("spellcheck",String(this.spellcheck_));var n=this.getConstants().FIELD_TEXT_FONTSIZE*t+"pt";e.style.fontSize=n,i.style.fontSize=n,i.style.borderRadius=Ts.BORDERRADIUS*t+"px",n=this.getConstants().FIELD_BORDER_RECT_X_PADDING*t;const u=this.getConstants().FIELD_BORDER_RECT_Y_PADDING*t/2;return i.style.padding=u+"px "+n+"px "+u+"px "+n+"px",n=this.getConstants().FIELD_TEXT_HEIGHT+this.getConstants().FIELD_BORDER_RECT_Y_PADDING,i.style.lineHeight=n*t+"px",e.appendChild(i),i.value=i.defaultValue=this.getEditorText_(this.value_),i.setAttribute("data-untyped-default-value",String(this.value_)),i.setAttribute("data-old-value",""),Hc?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(i),i}setMaxLines(e){typeof e=="number"&&0u&&(u=X),b+=this.getConstants().FIELD_TEXT_HEIGHT+(0this.maxDisplayLength&&(e[X]=e[X].substring(0,this.maxDisplayLength)),G.textContent=e[X];const re=L(G,t,i,n);re>u&&(u=re)}u+=this.htmlInput_.offsetWidth-this.htmlInput_.clientWidth}this.borderRect_&&(b+=2*this.getConstants().FIELD_BORDER_RECT_Y_PADDING,u+=2*this.getConstants().FIELD_BORDER_RECT_X_PADDING,this.borderRect_.setAttribute("width",`${u}`),this.borderRect_.setAttribute("height",`${b}`)),this.size_.width=u,this.size_.height=b,this.positionBorderRect_()}showEditor_(e,t){super.showEditor_(e,t),this.forceRerender()}widgetCreate_(){const e=En(),t=this.workspace_.getScale(),i=document.createElement("textarea");i.className="blocklyHtmlInput blocklyHtmlTextAreaInput",i.setAttribute("spellcheck",String(this.spellcheck_));var n=this.getConstants().FIELD_TEXT_FONTSIZE*t+"pt";e.style.fontSize=n,i.style.fontSize=n,i.style.borderRadius=Es.BORDERRADIUS*t+"px",n=this.getConstants().FIELD_BORDER_RECT_X_PADDING*t;const u=this.getConstants().FIELD_BORDER_RECT_Y_PADDING*t/2;return i.style.padding=u+"px "+n+"px "+u+"px "+n+"px",n=this.getConstants().FIELD_TEXT_HEIGHT+this.getConstants().FIELD_BORDER_RECT_Y_PADDING,i.style.lineHeight=n*t+"px",e.appendChild(i),i.value=i.defaultValue=this.getEditorText_(this.value_),i.setAttribute("data-untyped-default-value",String(this.value_)),i.setAttribute("data-old-value",""),Hc?setTimeout(this.resizeEditor_.bind(this),0):this.resizeEditor_(),this.bindInputEvents_(i),i}setMaxLines(e){typeof e=="number"&&0this.max_&&(e.max=`${this.max_}`,st(e,it.VALUEMAX,this.max_)),e}static fromJson(e){return new this(e.value,void 0,void 0,void 0,void 0,e)}};Xt("field_number",Gh),Gh.prototype.DEFAULT_VALUE=0;var Ar=class extends Oi{constructor(e,t,i,n,u){super(Pe.SKIP_SETUP),this.defaultType_="",this.variableTypes=[],this.variable_=null,this.SERIALIZABLE=!0,this.menuGenerator_=Ar.dropdownCreate,this.defaultVariableName=typeof e=="string"?e:"",this.size_=new Tt(0,0),e!==Pe.SKIP_SETUP&&(u?this.configure_(u):this.setTypes_(i,n),t&&this.setValidator(t))}configure_(e){super.configure_(e),this.setTypes_(e.variableTypes,e.defaultType)}initModel(){var e=this.getSourceBlock();if(!e)throw new pt;this.variable_||(e=Ls(e.workspace,null,this.defaultVariableName,this.defaultType_),this.doValueUpdate_(e.getId()))}shouldAddBorderRect_(){const e=this.getSourceBlock();if(!e)throw new pt;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 pt;const i=e.getAttribute("id"),n=e.textContent,u=e.getAttribute("variabletype")||e.getAttribute("variableType")||"";if(t=Ls(t.workspace,i,n,u),u!==null&&u!==t.type)throw Error("Serialized variable type with id '"+t.getId()+"' had type "+t.type+", and does not match variable field that references it: "+wi(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(Ar);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 pt;this.loadLegacyState(Ar,e)||(e=Ls(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 pt;return t=Ms(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 pt;this.variable_=Ms(t.workspace,e),super.doValueUpdate_(e)}typeIsAllowed_(e){const t=this.getVariableTypes_();if(!t)return!0;for(let i=0;ithis.max_&&(e.max=`${this.max_}`,st(e,it.VALUEMAX,this.max_)),e}static fromJson(e){return new this(e.value,void 0,void 0,void 0,void 0,e)}};Yt("field_number",Gh),Gh.prototype.DEFAULT_VALUE=0;var kr=class extends Oi{constructor(e,t,i,n,u){super(Pe.SKIP_SETUP),this.defaultType_="",this.variableTypes=[],this.variable_=null,this.SERIALIZABLE=!0,this.menuGenerator_=kr.dropdownCreate,this.defaultVariableName=typeof e=="string"?e:"",this.size_=new Tt(0,0),e!==Pe.SKIP_SETUP&&(u?this.configure_(u):this.setTypes_(i,n),t&&this.setValidator(t))}configure_(e){super.configure_(e),this.setTypes_(e.variableTypes,e.defaultType)}initModel(){var e=this.getSourceBlock();if(!e)throw new pt;this.variable_||(e=Ls(e.workspace,null,this.defaultVariableName,this.defaultType_),this.doValueUpdate_(e.getId()))}shouldAddBorderRect_(){const e=this.getSourceBlock();if(!e)throw new pt;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 pt;const i=e.getAttribute("id"),n=e.textContent,u=e.getAttribute("variabletype")||e.getAttribute("variableType")||"";if(t=Ls(t.workspace,i,n,u),u!==null&&u!==t.type)throw Error("Serialized variable type with id '"+t.getId()+"' had type "+t.type+", and does not match variable field that references it: "+wi(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(kr);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 pt;this.loadLegacyState(kr,e)||(e=Ls(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 pt;return t=Ms(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 pt;this.variable_=Ms(t.workspace,e),super.doValueUpdate_(e)}typeIsAllowed_(e){const t=this.getVariableTypes_();if(!t)return!0;for(let i=0;i(this.flyout_?r.config$$module$build$src$core$config.flyoutDragRadius:r.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 ' + - 'flyout's target workspace is undefined`);return!this.flyout_.isScrollable()||this.flyout_.isDragTowardWorkspace(this.currentDragDeltaXY_)?(this.startWorkspace_=this.flyout_.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),Y()||z(!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 df(this.startWorkspace_),this.workspaceDragger_.startDrag())}updateIsDragging_(){if(this.calledUpdateIsDragging_)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging_=!0,this.updateIsDraggingBubble_()||this.updateIsDraggingBlock_()||this.updateIsDraggingWorkspace_()}startDraggingBlock_(){this.blockDragger_=new(c(pe.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 lf(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,Ds(e)?this.cancel():(this.hasStarted_=!0,Kn(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=jl(),this.startWorkspace_.hideChaff(!!this.flyout_),this.startWorkspace_.markFocused(),this.mostRecentEvent_=e,ga(),this.targetBlock_&&this.targetBlock_.select(),Bi(e)?this.handleRightClick(e):(e.type.toLowerCase()==="pointerdown"&&e.pointerType!=="mouse"&&kl(e,this),this.mouseDownXY_=new ge(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(ve(document,"pointerdown",null,this.handleStart.bind(this),!0)),this.boundEvents.push(ve(document,"pointermove",null,this.handleMove.bind(this),!0)),this.boundEvents.push(ve(document,"pointerup",null,this.handleUp.bind(this),!0)),e.preventDefault(),e.stopPropagation()}handleStart(e){this.isDragging()||(this.handleTouchStart(e),this.isMultiTouch()&&Ei())}handleMove(e){this.isDragging()&&Ns(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),Ei())}handleUp(e){if(this.isDragging()||this.handleTouchEnd(e),!this.isMultiTouch()||this.isDragging()){if(!Ns(e))return;if(this.updateFromEvent_(e),Ei(),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=Un(e);this.cachedPoints.set(t,this.getTouchPoint(e));var i=Array.from(this.cachedPoints.keys());i.length===2&&(t=this.cachedPoints.get(i[0]),i=this.cachedPoints.get(i[1]),this.startDistance_=ge.distance(t,i),this.isMultiTouch_=!0,e.preventDefault())}handleTouchMove(e){const t=Un(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()),i=this.cachedPoints.get(t[0]);if(t=this.cachedPoints.get(t[1]),i=ge.distance(i,t)/this.startDistance_,0this.previousScale_){if(t=i-this.previousScale_,t=0this.cachedPoints.size&&(this.cachedPoints.clear(),this.previousScale_=0)}getTouchPoint(e){return this.startWorkspace_?new ge(e.pageX,e.pageY):null}isMultiTouch(){return this.isMultiTouch_}cancel(){this.isEnding_||(Ei(),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){O(new(le(on))(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 St&&(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()&&(Y()||z(!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(le(on))(this.startBlock_,this.startWorkspace_.id,"block");O(e)}this.bringBlockToFront_(),z(!1)}doWorkspaceClick_(e){e=this.creatorWorkspace,k()&&k().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=h();for(let t=0,i;i=e[t];t++)if(i.currentGesture_)return!0;return!1}},Vh=class{constructor(e,t){this.pattern=e;let i;this.spacing=(i=t.spacing)!=null?i:0;let n;this.length=(n=t.length)!=null?n:1,this.line2=(this.line1=e.firstChild)&&this.line1.nextSibling;let u;this.snapToGrid=(u=t.snap)!=null?u:!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 i=t-this.length/2,n=t+this.length/2;t*=e,i*=e,n*=e,this.setLineAttributes(this.line1,e,i,n,t,t),this.setLineAttributes(this.line2,e,t,t,i,n)}setLineAttributes(e,t,i,n,u,E){e&&(e.setAttribute("stroke-width",`${t}`),e.setAttribute("x1",`${i}`),e.setAttribute("y1",`${u}`),e.setAttribute("x2",`${n}`),e.setAttribute("y2",`${E}`))}moveTo(e,t){this.pattern.setAttribute("x",`${e}`),this.pattern.setAttribute("y",`${t}`)}static createDom(e,t,i){e=ee(q.PATTERN,{id:"blocklyGridPattern"+e,patternUnits:"userSpaceOnUse"},i);let n,u;if(0<((n=t.length)!=null?n:1)&&0<((u=t.spacing)!=null?u:0)){ee(q.LINE,{stroke:t.colour},e);let E;(E=t.length)!=null&&E&&ee(q.LINE,{stroke:t.colour},e)}else ee(q.LINE,{},e);return e}},Nt=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: -Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),null)}populateVariables(e){e=Yr(e);for(let t=0;trect,`,`${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;","}"]}},vf=!1,Zt=class{constructor(e){this.constants=e,this.debugElements_=[],this.svgRoot_=null,this.randomColour_=""}clearElems(){for(let e=0;ee.height;u&&(t-=n),this.debugElements_.push(ee(q.RECT,{class:"rowSpacerRect blockRenderDebug",x:i?-(e.xPos+e.width):e.xPos,y:t,width:e.width,height:n,stroke:u?"black":"blue",fill:"blue","fill-opacity":"0.5","stroke-width":"1px"},this.svgRoot_))}}drawSpacerElem(e,t,i){if(Zt.config.elemSpacers){t=Math.abs(e.width);var n=0>e.width,u=n?e.xPos-t:e.xPos;i&&(u=-(u+t)),this.debugElements_.push(ee(q.RECT,{class:"elemSpacerRect blockRenderDebug",x:u,y:e.centerline-e.height/2,width:t,height:e.height,stroke:"pink",fill:n?"black":"pink","fill-opacity":"0.5","stroke-width":"1px"},this.svgRoot_))}}drawRenderedElem(e,t){if(Zt.config.elems){let i=e.xPos;t&&(i=-(i+e.width)),t=e.centerline-e.height/2,this.debugElements_.push(ee(q.RECT,{class:"rowRenderingRect blockRenderDebug",x:i,y:t,width:e.width,height:e.height,stroke:"black",fill:"none","stroke-width":"1px"},this.svgRoot_)),Z.isField(e)&&e instanceof xn&&e.field instanceof hn&&this.debugElements_.push(ee(q.RECT,{class:"rowRenderingRect blockRenderDebug",x:i,y:t+this.constants.FIELD_TEXT_BASELINE,width:e.width,height:"0.1px",stroke:"red",fill:"none","stroke-width":"0.5px"},this.svgRoot_))}Z.isInput(e)&&e instanceof Yi&&Zt.config.connections&&this.drawConnection(e.connectionModel)}drawConnection(e){if(Zt.config.connections){var t="",i=0,n="";e.type===$e.INPUT_VALUE?(i=4,t="magenta",n="none"):e.type===$e.OUTPUT_VALUE?(i=2,n=t="magenta"):e.type===$e.NEXT_STATEMENT?(i=4,t="goldenrod",n="none"):e.type===$e.PREVIOUS_STATEMENT&&(i=2,n=t="goldenrod"),this.debugElements_.push(ee(q.CIRCLE,{class:"blockRenderDebug",cx:e.getOffsetInBlock().x,cy:e.getOffsetInBlock().y,r:i,fill:n,stroke:t},this.svgRoot_))}}drawRenderedRow(e,t,i){Zt.config.rows&&(this.debugElements_.push(ee(q.RECT,{class:"elemRenderingRect blockRenderDebug",x:i?-(e.xPos+e.width):e.xPos,y:e.yPos,width:e.width,height:e.height,stroke:"red",fill:"none","stroke-width":"1px"},this.svgRoot_)),Z.isTopOrBottomRow(e)||Zt.config.connectedBlockBounds&&this.debugElements_.push(ee(q.RECT,{class:"connectedBlockWidth blockRenderDebug",x:i?-(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,i){for(let n=0;n{u&&t&&this.deleteVariableInternal(t,n)})):this.deleteVariableInternal(t,n)}else console.warn("Can't delete non-existent variable: "+e)}deleteVariableInternal(e,t){const i=Y();i||z(!0);try{for(let n=0;ne.name)}getVariableUsesById(e){const t=[],i=this.workspace.getAllBlocks(!1);for(let n=0;nthis.remainingCapacityOfType(i))return!1;t+=e[i]}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_,i=e?this.undoStack_:this.redoStack_;const n=t.pop();if(n){for(var u=[n];t.length&&n.group&&n.group===t[t.length-1].group;){const E=t.pop();E&&u.push(E)}for(t=0;tthis.MAX_UNDO&&0<=this.MAX_UNDO;)this.undoStack_.shift();for(let t=0;t(this.flyout_?s.config$$module$build$src$core$config.flyoutDragRadius:s.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 ' + + 'flyout's target workspace is undefined`);return!this.flyout_.isScrollable()||this.flyout_.isDragTowardWorkspace(this.currentDragDeltaXY_)?(this.startWorkspace_=this.flyout_.targetWorkspace,this.startWorkspace_.updateScreenCalculationsIfScrolled(),Y()||z(!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 uf(this.startWorkspace_),this.workspaceDragger_.startDrag())}updateIsDragging_(){if(this.calledUpdateIsDragging_)throw Error("updateIsDragging_ should only be called once per gesture.");this.calledUpdateIsDragging_=!0,this.updateIsDraggingBubble_()||this.updateIsDraggingBlock_()||this.updateIsDraggingWorkspace_()}startDraggingBlock_(){this.blockDragger_=new(c(pe.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 of(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,Ds(e)?this.cancel():(this.hasStarted_=!0,jn(),this.startWorkspace_.updateScreenCalculationsIfScrolled(),this.startWorkspace_.isMutator&&this.startWorkspace_.resize(),this.currentDropdownOwner=jl(),this.startWorkspace_.hideChaff(!!this.flyout_),this.startWorkspace_.markFocused(),this.mostRecentEvent_=e,ga(),this.targetBlock_&&this.targetBlock_.select(),Bi(e)?this.handleRightClick(e):(e.type.toLowerCase()==="pointerdown"&&e.pointerType!=="mouse"&&Al(e,this),this.mouseDownXY_=new ge(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(ve(document,"pointerdown",null,this.handleStart.bind(this),!0)),this.boundEvents.push(ve(document,"pointermove",null,this.handleMove.bind(this),!0)),this.boundEvents.push(ve(document,"pointerup",null,this.handleUp.bind(this),!0)),e.preventDefault(),e.stopPropagation()}handleStart(e){this.isDragging()||(this.handleTouchStart(e),this.isMultiTouch()&&Ei())}handleMove(e){this.isDragging()&&Ns(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),Ei())}handleUp(e){if(this.isDragging()||this.handleTouchEnd(e),!this.isMultiTouch()||this.isDragging()){if(!Ns(e))return;if(this.updateFromEvent_(e),Ei(),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=Hn(e);this.cachedPoints.set(t,this.getTouchPoint(e));var i=Array.from(this.cachedPoints.keys());i.length===2&&(t=this.cachedPoints.get(i[0]),i=this.cachedPoints.get(i[1]),this.startDistance_=ge.distance(t,i),this.isMultiTouch_=!0,e.preventDefault())}handleTouchMove(e){const t=Hn(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()),i=this.cachedPoints.get(t[0]);if(t=this.cachedPoints.get(t[1]),i=ge.distance(i,t)/this.startDistance_,0this.previousScale_){if(t=i-this.previousScale_,t=0this.cachedPoints.size&&(this.cachedPoints.clear(),this.previousScale_=0)}getTouchPoint(e){return this.startWorkspace_?new ge(e.pageX,e.pageY):null}isMultiTouch(){return this.isMultiTouch_}cancel(){this.isEnding_||(Ei(),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){k(new(le(on))(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 St&&(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()&&(Y()||z(!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(le(on))(this.startBlock_,this.startWorkspace_.id,"block");k(e)}this.bringBlockToFront_(),z(!1)}doWorkspaceClick_(e){e=this.creatorWorkspace,M()&&M().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=h();for(let t=0,i;i=e[t];t++)if(i.currentGesture_)return!0;return!1}},Vh=class{constructor(e,t){this.pattern=e;let i;this.spacing=(i=t.spacing)!=null?i:0;let n;this.length=(n=t.length)!=null?n:1,this.line2=(this.line1=e.firstChild)&&this.line1.nextSibling;let u;this.snapToGrid=(u=t.snap)!=null?u:!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 i=t-this.length/2,n=t+this.length/2;t*=e,i*=e,n*=e,this.setLineAttributes(this.line1,e,i,n,t,t),this.setLineAttributes(this.line2,e,t,t,i,n)}setLineAttributes(e,t,i,n,u,b){e&&(e.setAttribute("stroke-width",`${t}`),e.setAttribute("x1",`${i}`),e.setAttribute("y1",`${u}`),e.setAttribute("x2",`${n}`),e.setAttribute("y2",`${b}`))}moveTo(e,t){this.pattern.setAttribute("x",`${e}`),this.pattern.setAttribute("y",`${t}`)}static createDom(e,t,i){e=ee(q.PATTERN,{id:"blocklyGridPattern"+e,patternUnits:"userSpaceOnUse"},i);let n,u;if(0<((n=t.length)!=null?n:1)&&0<((u=t.spacing)!=null?u:0)){ee(q.LINE,{stroke:t.colour},e);let b;(b=t.length)!=null&&b&&ee(q.LINE,{stroke:t.colour},e)}else ee(q.LINE,{},e);return e}},Nt=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: +Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`),null)}populateVariables(e){e=Yr(e);for(let t=0;trect,`,`${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;","}"]}},$f=!1,Qt=class{constructor(e){this.constants=e,this.debugElements_=[],this.svgRoot_=null,this.randomColour_=""}clearElems(){for(let e=0;ee.height;u&&(t-=n),this.debugElements_.push(ee(q.RECT,{class:"rowSpacerRect blockRenderDebug",x:i?-(e.xPos+e.width):e.xPos,y:t,width:e.width,height:n,stroke:u?"black":"blue",fill:"blue","fill-opacity":"0.5","stroke-width":"1px"},this.svgRoot_))}}drawSpacerElem(e,t,i){if(Qt.config.elemSpacers){t=Math.abs(e.width);var n=0>e.width,u=n?e.xPos-t:e.xPos;i&&(u=-(u+t)),this.debugElements_.push(ee(q.RECT,{class:"elemSpacerRect blockRenderDebug",x:u,y:e.centerline-e.height/2,width:t,height:e.height,stroke:"pink",fill:n?"black":"pink","fill-opacity":"0.5","stroke-width":"1px"},this.svgRoot_))}}drawRenderedElem(e,t){if(Qt.config.elems){let i=e.xPos;t&&(i=-(i+e.width)),t=e.centerline-e.height/2,this.debugElements_.push(ee(q.RECT,{class:"rowRenderingRect blockRenderDebug",x:i,y:t,width:e.width,height:e.height,stroke:"black",fill:"none","stroke-width":"1px"},this.svgRoot_)),Z.isField(e)&&e instanceof Bn&&e.field instanceof hn&&this.debugElements_.push(ee(q.RECT,{class:"rowRenderingRect blockRenderDebug",x:i,y:t+this.constants.FIELD_TEXT_BASELINE,width:e.width,height:"0.1px",stroke:"red",fill:"none","stroke-width":"0.5px"},this.svgRoot_))}Z.isInput(e)&&e instanceof Yi&&Qt.config.connections&&this.drawConnection(e.connectionModel)}drawConnection(e){if(Qt.config.connections){var t="",i=0,n="";e.type===$e.INPUT_VALUE?(i=4,t="magenta",n="none"):e.type===$e.OUTPUT_VALUE?(i=2,n=t="magenta"):e.type===$e.NEXT_STATEMENT?(i=4,t="goldenrod",n="none"):e.type===$e.PREVIOUS_STATEMENT&&(i=2,n=t="goldenrod"),this.debugElements_.push(ee(q.CIRCLE,{class:"blockRenderDebug",cx:e.getOffsetInBlock().x,cy:e.getOffsetInBlock().y,r:i,fill:n,stroke:t},this.svgRoot_))}}drawRenderedRow(e,t,i){Qt.config.rows&&(this.debugElements_.push(ee(q.RECT,{class:"elemRenderingRect blockRenderDebug",x:i?-(e.xPos+e.width):e.xPos,y:e.yPos,width:e.width,height:e.height,stroke:"red",fill:"none","stroke-width":"1px"},this.svgRoot_)),Z.isTopOrBottomRow(e)||Qt.config.connectedBlockBounds&&this.debugElements_.push(ee(q.RECT,{class:"connectedBlockWidth blockRenderDebug",x:i?-(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,i){for(let n=0;n{u&&t&&this.deleteVariableInternal(t,n)})):this.deleteVariableInternal(t,n)}else console.warn("Can't delete non-existent variable: "+e)}deleteVariableInternal(e,t){const i=Y();i||z(!0);try{for(let n=0;ne.name)}getVariableUsesById(e){const t=[],i=this.workspace.getAllBlocks(!1);for(let n=0;nthis.remainingCapacityOfType(i))return!1;t+=e[i]}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_,i=e?this.undoStack_:this.redoStack_;const n=t.pop();if(n){for(var u=[n];t.length&&n.group&&n.group===t[t.length-1].group;){const b=t.pop();b&&u.push(b)}for(t=0;tthis.MAX_UNDO&&0<=this.MAX_UNDO;)this.undoStack_.shift();for(let t=0;timage, .blocklyZoom>svg>image { opacity: .4; } @@ -662,16 +662,16 @@ Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`), .blocklyZoom>image:active, .blocklyZoom>svg>image:active { opacity: .8; } -`);var r_=20,_i=class extends Pr{constructor(e,t,i){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(c(pe.METRICS_MANAGER,e,!0))(this),this.getMetrics=e.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager),this.setMetrics=e.setMetrics||_i.setTopLevelWorkspaceMetrics_,this.componentManager=new Et,this.connectionDBList=vs.init(this.connectionChecker),t&&(this.blockDragSurface=t),i&&(this.workspaceDragSurface=i),this.useWorkspaceDragSurface=!!this.workspaceDragSurface,this.audioManager=new Ef(e.parentWorkspace),this.grid=this.options.gridPattern?new Vh(this.options.gridPattern,e.gridOptions):null,this.markerManager=new mr(this),r.module$build$src$core$variables&&Kr&&this.registerToolboxCategoryCallback(Po,Kr),dn&&ko&&this.registerToolboxCategoryCallback(Qh,ko),r.module$build$src$core$procedures&&Co&&(this.registerToolboxCategoryCallback(ll,Co),this.addChangeListener(cc)),this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new Tf(this,this.options.theme||tl),this.themeManager_.subscribeWorkspace(this);let n;this.renderer=dc(this.options.renderer||"geras",this.getTheme(),(n=this.options.rendererOverrides)!=null?n:void 0),this.cachedParentSvgSize=new Tt(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=tl),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(le(ar))(this.getTheme().name,this.id);O(e)}updateBlockStyles_(e){for(let t=0,i;i=e[t];t++){const n=i.getStyleName();if(n){const u=i;u.setStyle(n),u.mutator&&u.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,i=0,n=1;(Ne(this.getCanvas(),e)||Ne(this.getBubbleCanvas(),e))&&(n=this.scale);do{const u=ei(e);(e===this.getCanvas()||e===this.getBubbleCanvas())&&(n=1),t+=u.x*n,i+=u.y*n,e=e.parentNode}while(e&&e!==this.getParentSvg());return new ge(t,i)}getCachedParentSvgSize(){const e=this.cachedParentSvgSize;return new Tt(e.width,e.height)}getOriginOffsetInPixels(){return Ps(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_=ee(q.G,{class:"blocklyWorkspace"}),e&&(this.svgBackground_=ee(q.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_=ee(q.G,{class:"blocklyBlockCanvas"},this.svgGroup_),this.svgBubbleCanvas_=ee(q.G,{class:"blocklyBubbleCanvas"},this.svgGroup_),this.isFlyout||(ve(this.svgGroup_,"pointerdown",this,this.onMouseDown_,!1),document.body.addEventListener("wheel",function(){}),ve(this.svgGroup_,"wheel",this,this.onMouseWheel_)),this.options.hasCategories&&(this.toolbox_=new(c(pe.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(e=c(pe.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_&&ue(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&&ue(e.parentNode)}this.resizeHandlerWrapper&&(je(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null)}addTrashcan(){this.trashcan=_i.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 bf(this);const e=this.zoomControls_.createDom();this.svgGroup_.appendChild(e)}addFlyout(e){const t=new fi({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(c(pe.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(t):new(c(pe.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(Et.Capability.POSITIONABLE,!0),t=this.getMetricsManager().getUiMetrics(),i=[];for(let n=0,u;u=e[n];n++){u.position(t,i);const E=u.getBoundingRectangle();E&&i.push(E)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations_()}updateScreenCalculationsIfScrolled(){const e=eo();ge.equals(this.lastRecordedPageScroll,e)||(this.lastRecordedPageScroll=e,this.updateScreenCalculations_())}getCanvas(){return this.svgBlockCanvas_}setCachedParentSvgSize(e,t){const i=this.getParentSvg();e!=null&&(this.cachedParentSvgSize.width=e,i.setAttribute("data-cached-width",`${e}`)),t!=null&&(this.cachedParentSvgSize.height=t,i.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(J()){var e=this.scale,t=-this.scrollY,i=-this.scrollX;if(!(e===this.oldScale&&1>Math.abs(t-this.oldTop)&&1>Math.abs(i-this.oldLeft))){var n=new(le(yn))(t,i,e,this.id,this.oldScale);this.oldScale=e,this.oldTop=t,this.oldLeft=i,O(n)}}}translate(e,t){if(this.useWorkspaceDragSurface&&this.isDragSurfaceActive){var i;(i=this.workspaceDragSurface)==null||i.translateSurface(e,t)}else i="translate("+e+","+t+") scale("+this.scale+")",this.svgBlockCanvas_.setAttribute("transform",i),this.svgBubbleCanvas_.setAttribute("transform",i);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,i=parseInt((t=this.getParentSvg().getAttribute("width"))!=null?t:"0"),n;t=parseInt((n=this.getParentSvg().getAttribute("height"))!=null?n:"0"),n=ei(this.getCanvas()),this.workspaceDragSurface.setContentsAndShow(this.getCanvas(),this.getBubbleCanvas(),e,i,t,this.scale),this.workspaceDragSurface.translateSurface(n.x,n.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=Math.abs(n-me.x)&&1>=Math.abs(u-me.y)){E=!0;break}}if(!E){const X=i.getConnections_(!1);for(let re=0,me;me=X[re];re++)if(me.closest(r.config$$module$build$src$core$config.snapRadius,new ge(n,u)).connection){E=!0;break}}E&&(n=this.RTL?n-r.config$$module$build$src$core$config.snapRadius:n+r.config$$module$build$src$core$config.snapRadius,u+=2*r.config$$module$build$src$core$config.snapRadius)}while(E);i.moveTo(new ge(n,u))}}finally{ie()}return J()&&!i.isShadow()&&O(new(le(wt))(i)),i.select(),i}pasteWorkspaceComment_(e){Q();let t;try{t=St.fromXmlRendered(e,this);let i,n=parseInt((i=e.getAttribute("x"))!=null?i:"0"),u,E=parseInt((u=e.getAttribute("y"))!=null?u:"0");isNaN(n)||isNaN(E)||(this.RTL&&(n=-n),t.moveBy(n+50,E+50))}finally{ie()}return J()&&ki.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,i){return e=super.createVariable(e,t,i),this.refreshToolboxSelection(),e}recordDragTargets(){const e=this.componentManager.getComponents(Et.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let t=0,i;i=e[t];t++){const n=i.getClientRect();n&&this.dragTargetAreas.push({component:i,clientRect:n})}}newBlock(e,t){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}getDragTarget(e){for(let t=0,i;i=this.dragTargetAreas[t];t++)if(i.clientRect.contains(e.clientX,e.clientY))return i.component;return null}onMouseDown_(e){const t=this.getGesture(e);t&&t.handleWsStart(e,this)}startDrag(e,t){e=mn(e,this.getParentSvg(),this.getInverseScreenCTM()),e.x/=this.scale,e.y/=this.scale,this.dragDeltaXY=ge.difference(t,e)}moveDrag(e){return e=mn(e,this.getParentSvg(),this.getInverseScreenCTM()),e.x/=this.scale,e.y/=this.scale,ge.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(Li.inProgress())e.preventDefault(),e.stopPropagation();else{var t=this.options.zoomOptions&&this.options.zoomOptions.wheel,i=this.options.moveOptions&&this.options.moveOptions.wheel;if(t||i){var n=xs(e);if(Vc)var u=e.metaKey;t&&(e.ctrlKey||u||!i)?(n=-n.y/50,t=mn(e,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(t.x,t.y,n)):(t=this.scrollX-n.x,i=this.scrollY-n.y,e.shiftKey&&!n.x&&(t=this.scrollX-n.y,i=this.scrollY),this.scroll(t,i)),e.preventDefault()}}}getBlocksBoundingBox(){const e=this.getTopBoundedElements();if(!e.length)return new ct(0,0,0,0);const t=e[0].getBoundingRectangle();for(let n=1;nt.bottom&&(t.bottom=i.bottom),i.leftt.right&&(t.right=i.right))}return t}cleanUp(){this.setResizesEnabled(!1),z(!0);const e=this.getTopBlocks(!0);let t=0;for(let i=0,n;n=e[i];i++){if(!n.isMovable())continue;const u=n.getRelativeToSurfaceXY();n.moveBy(-u.x,t-u.y),n.snapToGrid(),t=n.getRelativeToSurfaceXY().y+n.getHeightWidth().height+this.renderer.getConstants().MIN_BLOCK_HEIGHT}z(!1),this.setResizesEnabled(!0)}showContextMenu(e){if(!this.options.readOnly&&!this.isFlyout){var t=Xe.registry.getContextMenuOptions(Xe.ScopeType.WORKSPACE,{workspace:this});this.configureContextMenu&&this.configureContextMenu(t,e),Zs(e,t,this.RTL)}}updateToolbox(e){if(e=Xs(e)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(_o(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():(v(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(e,t,i){i=Math.pow(this.options.zoomOptions.scaleSpeed,i);const n=this.scale*i;if(this.scale!==n){n>this.options.zoomOptions.maxScale?i=this.options.zoomOptions.maxScale/this.scale:nthis.options.zoomOptions.maxScale?e=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&ei.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)}},ys;(function(e){e.BLOCK="block",e.BUTTON="button"})(ys||(ys={}));var hl=class extends rl{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 _i(e),this.workspace_.setMetricsManager(new uf(this.workspace_,this)),this.workspace_.internalIsFlyout=!0,this.workspace_.setVisible(this.isVisible_),this.id=A(),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_=ee(e,{class:"blocklyFlyout",style:"display: none"}),this.svgBackground_=ee(q.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 Hh(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN),this.hide(),this.boundEvents.push(ve(this.svgGroup_,"wheel",this,this.wheel_)),this.autoClose||(this.filterWrapper_=this.filterForCapacity_.bind(this),this.targetWorkspace.addChangeListener(this.filterWrapper_)),this.boundEvents.push(ve(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:[Et.Capability.DELETE_AREA,Et.Capability.DRAG_TARGET]})}dispose(){this.hide(),this.workspace_.getComponentManager().removeComponent(this.id);for(const e of this.boundEvents)je(e);this.boundEvents.length=0,this.filterWrapper_&&(this.targetWorkspace.removeChangeListener(this.filterWrapper_),this.filterWrapper_=null),this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose()),this.svgGroup_&&(ue(this.svgGroup_),this.svgGroup_=null),this.svgBackground_=null}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,i,n){let u;(u=this.svgGroup_)==null||u.setAttribute("width",`${e}`);let E;(E=this.svgGroup_)==null||E.setAttribute("height",`${t}`),this.workspace_.setCachedParentSvgSize(e,t),this.svgGroup_&&Be(this.svgGroup_,"translate("+i+"px,"+n+"px)"),(e=this.workspace_.scrollbar)&&(e.setOrigin(i,n),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_)je(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=Ys(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=[],i=[];this.permanentlyDisabled_.length=0;const n=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(const u of e){if("custom"in u){e=this.getDynamicCategoryContents_(u.custom),e=Ys(e);const{contents:E,gaps:G}=this.createFlyoutInfo_(e);t.push(...E),i.push(...G)}switch(u.kind.toUpperCase()){case"BLOCK":e=u;const E=this.createFlyoutBlock_(e);t.push({type:ys.BLOCK,block:E}),this.addBlockGap_(e,i,n);break;case"SEP":this.addSeparatorGap_(u,i,n);break;case"LABEL":e=this.createButton_(u,!0),t.push({type:ys.BUTTON,button:e}),i.push(n);break;case"BUTTON":e=this.createButton_(u,!1),t.push({type:ys.BUTTON,button:e}),i.push(n)}}return{contents:t,gaps:i}}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 mi(this.workspace_,this.targetWorkspace,e,t)}createFlyoutBlock_(e){let t;return e.blockxml?(e=typeof e.blockxml=="string"?De(e.blockxml):e.blockxml,(t=this.getRecycledBlock_(e.getAttribute("type")))||(t=_n(e,this.workspace_))):(t=this.getRecycledBlock_(e.type),t||(e.enabled===void 0&&(e.enabled=e.disabled!=="true"&&e.disabled!==!0),t=qi(e,this.workspace_))),t.isEnabled()||this.permanentlyDisabled_.push(t),t}getRecycledBlock_(e){let t=-1;for(let i=0;i{const i=this.targetWorkspace.getGesture(t);i&&(i.setStartBlock(e),i.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;Q();var i=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{t=this.placeNewBlock_(e)}finally{ie()}if(this.targetWorkspace.hideChaff(),e=Zr(this.targetWorkspace,i),J()){for(z(!0),i=0;i90-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_===Ce.TOP?new ct(-1e9,t+e.height,-1e9,1e9):new ct(t,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=0;const t=this.workspace_.getTopBlocks(!1);for(let n=0,u;u=t[n];n++)e=Math.max(e,u.getHeightWidth().height);const i=this.buttons_;for(let n=0,u;u=i[n];n++)e=Math.max(e,u.height);if(e+=1.5*this.MARGIN,e*=this.workspace_.scale,e+=ot.scrollbarThickness,this.height_!==e){for(let n=0,u;u=t[n];n++)this.rectMap_.has(u)&&this.moveRectToBlock_(this.rectMap_.get(u),u);this.targetWorkspace.toolboxPosition!==this.toolboxPosition_||this.toolboxPosition_!==Ce.TOP||this.targetWorkspace.getToolbox()||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+e),this.height_=e,this.position(),this.targetWorkspace.recordDragTargets()}}};m(pe.FLYOUTS_HORIZONTAL_TOOLBOX,Fi,yf);var eu=class extends hl{constructor(e){super(e)}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),i=t.getScrollMetrics(),n=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.y=="number"&&(this.workspace_.scrollY=-(i.top+(i.height-n.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(),i=e.getViewMetrics();return e=e.getToolboxMetrics(),this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===Ce.LEFT?e.width:i.width-this.width_:this.toolboxPosition_===Ce.LEFT?0:i.width:this.toolboxPosition_===Ce.LEFT?0:i.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 i=this.toolboxPosition_===Ce.RIGHT;var n=e+this.CORNER_RADIUS;n=["M "+(i?n:0)+",0"],n.push("h",i?-e:e),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,i?0:1,i?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),n.push("v",Math.max(0,t)),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,i?0:1,i?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),n.push("h",i?e:-e),n.push("z"),this.svgBackground_.setAttribute("d",n.join(" "))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setY(0)}wheel_(e){var t=xs(e);if(t.y){const i=this.workspace_.getMetricsManager(),n=i.getScrollMetrics();t=i.getViewMetrics().top-n.top+t.y;let u;(u=this.workspace_.scrollbar)==null||u.setY(t),li(),oi()}e.preventDefault(),e.stopPropagation()}layout_(e,t){this.workspace_.scale=this.targetWorkspace.scale;var i=this.MARGIN;const n=this.RTL?i:i+this.tabWidth_;for(let X=0,re;re=e[X];X++)if(re.type==="block"){var u=re.block,E=u.getDescendants(!1);for(let lt=0,at;at=E[lt];lt++)at.isInFlyout=!0;u.render(),E=u.getSvgRoot();const me=u.getHeightWidth();var G=u.outputConnection?n-this.tabWidth_:n;u.moveBy(G,i),G=this.createRect_(u,this.RTL?G-me.width:G,i,me,X),this.addBlockListeners_(E,u,G),i+=me.height+t[X]}else re.type==="button"&&(u=re.button,this.initFlyoutButton_(u,n,i),i+=u.height+t[X])}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;const t=this.dragAngleRange_;return 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_===Ce.LEFT?new ct(-1e9,1e9,-1e9,t+e.width):new ct(-1e9,1e9,t,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=0;var t=this.workspace_.getTopBlocks(!1);for(let n=0,u;u=t[n];n++){var i=u.getHeightWidth().width;u.outputConnection&&(i-=this.tabWidth_),e=Math.max(e,i)}for(let n=0,u;u=this.buttons_[n];n++)e=Math.max(e,u.width);if(e+=1.5*this.MARGIN+this.tabWidth_,e*=this.workspace_.scale,e+=ot.scrollbarThickness,this.width_!==e){for(let n=0,u;u=t[n];n++){if(this.RTL){i=u.getRelativeToSurfaceXY().x;let E=e/this.workspace_.scale-this.MARGIN;u.outputConnection||(E-=this.tabWidth_),u.moveBy(E-i,0)}this.rectMap_.has(u)&&this.moveRectToBlock_(this.rectMap_.get(u),u)}if(this.RTL)for(let n=0,u;u=this.buttons_[n];n++)t=u.getPosition().y,u.moveTo(e/this.workspace_.scale-u.width-this.MARGIN-this.tabWidth_,t);this.targetWorkspace.toolboxPosition!==this.toolboxPosition_||this.toolboxPosition_!==Ce.LEFT||this.targetWorkspace.getToolbox()||this.targetWorkspace.translate(this.targetWorkspace.scrollX+e,this.targetWorkspace.scrollY),this.width_=e,this.position(),this.targetWorkspace.recordDragTargets()}}};eu.registryName="verticalFlyout",m(pe.FLYOUTS_VERTICAL_TOOLBOX,Fi,eu),r.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=_());var t=[];this.init(e),e=e.getTopBlocks(!0);for(let i=0,n;n=e[i];i++){let u=this.blockToCode(n);Array.isArray(u)&&(u=u[0]),u&&(n.outputConnection&&(u=this.scrubNakedValue(u),this.STATEMENT_PREFIX&&!n.suppressPrefixSuffix&&(u=this.injectId(this.STATEMENT_PREFIX,n)+u),this.STATEMENT_SUFFIX&&!n.suppressPrefixSuffix&&(u+=this.injectId(this.STATEMENT_SUFFIX,n))),t.push(u))}return t=t.join(` +`);var r_=20,_i=class extends Pr{constructor(e,t,i){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(c(pe.METRICS_MANAGER,e,!0))(this),this.getMetrics=e.getMetrics||this.metricsManager.getMetrics.bind(this.metricsManager),this.setMetrics=e.setMetrics||_i.setTopLevelWorkspaceMetrics_,this.componentManager=new Et,this.connectionDBList=Ts.init(this.connectionChecker),t&&(this.blockDragSurface=t),i&&(this.workspaceDragSurface=i),this.useWorkspaceDragSurface=!!this.workspaceDragSurface,this.audioManager=new Tf(e.parentWorkspace),this.grid=this.options.gridPattern?new Vh(this.options.gridPattern,e.gridOptions):null,this.markerManager=new mr(this),s.module$build$src$core$variables&&Kr&&this.registerToolboxCategoryCallback(Po,Kr),dn&&Ao&&this.registerToolboxCategoryCallback(Qh,Ao),s.module$build$src$core$procedures&&Co&&(this.registerToolboxCategoryCallback(ll,Co),this.addChangeListener(cc)),this.themeManager_=this.options.parentWorkspace?this.options.parentWorkspace.getThemeManager():new vf(this,this.options.theme||tl),this.themeManager_.subscribeWorkspace(this);let n;this.renderer=dc(this.options.renderer||"geras",this.getTheme(),(n=this.options.rendererOverrides)!=null?n:void 0),this.cachedParentSvgSize=new Tt(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=tl),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(le(ar))(this.getTheme().name,this.id);k(e)}updateBlockStyles_(e){for(let t=0,i;i=e[t];t++){const n=i.getStyleName();if(n){const u=i;u.setStyle(n),u.mutator&&u.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,i=0,n=1;(Ne(this.getCanvas(),e)||Ne(this.getBubbleCanvas(),e))&&(n=this.scale);do{const u=ti(e);(e===this.getCanvas()||e===this.getBubbleCanvas())&&(n=1),t+=u.x*n,i+=u.y*n,e=e.parentNode}while(e&&e!==this.getParentSvg());return new ge(t,i)}getCachedParentSvgSize(){const e=this.cachedParentSvgSize;return new Tt(e.width,e.height)}getOriginOffsetInPixels(){return Ps(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_=ee(q.G,{class:"blocklyWorkspace"}),e&&(this.svgBackground_=ee(q.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_=ee(q.G,{class:"blocklyBlockCanvas"},this.svgGroup_),this.svgBubbleCanvas_=ee(q.G,{class:"blocklyBubbleCanvas"},this.svgGroup_),this.isFlyout||(ve(this.svgGroup_,"pointerdown",this,this.onMouseDown_,!1),document.body.addEventListener("wheel",function(){}),ve(this.svgGroup_,"wheel",this,this.onMouseWheel_)),this.options.hasCategories&&(this.toolbox_=new(c(pe.TOOLBOX,this.options,!0))(this)),this.grid&&this.grid.update(this.scale),this.recordDragTargets(),(e=c(pe.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_&&ue(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&&ue(e.parentNode)}this.resizeHandlerWrapper&&(Je(this.resizeHandlerWrapper),this.resizeHandlerWrapper=null)}addTrashcan(){this.trashcan=_i.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 Ef(this);const e=this.zoomControls_.createDom();this.svgGroup_.appendChild(e)}addFlyout(e){const t=new fi({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(c(pe.FLYOUTS_HORIZONTAL_TOOLBOX,this.options,!0))(t):new(c(pe.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(Et.Capability.POSITIONABLE,!0),t=this.getMetricsManager().getUiMetrics(),i=[];for(let n=0,u;u=e[n];n++){u.position(t,i);const b=u.getBoundingRectangle();b&&i.push(b)}this.scrollbar&&this.scrollbar.resize(),this.updateScreenCalculations_()}updateScreenCalculationsIfScrolled(){const e=eo();ge.equals(this.lastRecordedPageScroll,e)||(this.lastRecordedPageScroll=e,this.updateScreenCalculations_())}getCanvas(){return this.svgBlockCanvas_}setCachedParentSvgSize(e,t){const i=this.getParentSvg();e!=null&&(this.cachedParentSvgSize.width=e,i.setAttribute("data-cached-width",`${e}`)),t!=null&&(this.cachedParentSvgSize.height=t,i.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(J()){var e=this.scale,t=-this.scrollY,i=-this.scrollX;if(!(e===this.oldScale&&1>Math.abs(t-this.oldTop)&&1>Math.abs(i-this.oldLeft))){var n=new(le(wn))(t,i,e,this.id,this.oldScale);this.oldScale=e,this.oldTop=t,this.oldLeft=i,k(n)}}}translate(e,t){if(this.useWorkspaceDragSurface&&this.isDragSurfaceActive){var i;(i=this.workspaceDragSurface)==null||i.translateSurface(e,t)}else i="translate("+e+","+t+") scale("+this.scale+")",this.svgBlockCanvas_.setAttribute("transform",i),this.svgBubbleCanvas_.setAttribute("transform",i);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,i=parseInt((t=this.getParentSvg().getAttribute("width"))!=null?t:"0"),n;t=parseInt((n=this.getParentSvg().getAttribute("height"))!=null?n:"0"),n=ti(this.getCanvas()),this.workspaceDragSurface.setContentsAndShow(this.getCanvas(),this.getBubbleCanvas(),e,i,t,this.scale),this.workspaceDragSurface.translateSurface(n.x,n.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=Math.abs(n-me.x)&&1>=Math.abs(u-me.y)){b=!0;break}}if(!b){const X=i.getConnections_(!1);for(let re=0,me;me=X[re];re++)if(me.closest(s.config$$module$build$src$core$config.snapRadius,new ge(n,u)).connection){b=!0;break}}b&&(n=this.RTL?n-s.config$$module$build$src$core$config.snapRadius:n+s.config$$module$build$src$core$config.snapRadius,u+=2*s.config$$module$build$src$core$config.snapRadius)}while(b);i.moveTo(new ge(n,u))}}finally{ie()}return J()&&!i.isShadow()&&k(new(le(wt))(i)),i.select(),i}pasteWorkspaceComment_(e){Q();let t;try{t=St.fromXmlRendered(e,this);let i,n=parseInt((i=e.getAttribute("x"))!=null?i:"0"),u,b=parseInt((u=e.getAttribute("y"))!=null?u:"0");isNaN(n)||isNaN(b)||(this.RTL&&(n=-n),t.moveBy(n+50,b+50))}finally{ie()}return J()&&Ai.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,i){return e=super.createVariable(e,t,i),this.refreshToolboxSelection(),e}recordDragTargets(){const e=this.componentManager.getComponents(Et.Capability.DRAG_TARGET,!0);this.dragTargetAreas=[];for(let t=0,i;i=e[t];t++){const n=i.getClientRect();n&&this.dragTargetAreas.push({component:i,clientRect:n})}}newBlock(e,t){throw Error("The implementation of newBlock should be monkey-patched in by blockly.ts")}getDragTarget(e){for(let t=0,i;i=this.dragTargetAreas[t];t++)if(i.clientRect.contains(e.clientX,e.clientY))return i.component;return null}onMouseDown_(e){const t=this.getGesture(e);t&&t.handleWsStart(e,this)}startDrag(e,t){e=_n(e,this.getParentSvg(),this.getInverseScreenCTM()),e.x/=this.scale,e.y/=this.scale,this.dragDeltaXY=ge.difference(t,e)}moveDrag(e){return e=_n(e,this.getParentSvg(),this.getInverseScreenCTM()),e.x/=this.scale,e.y/=this.scale,ge.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(Li.inProgress())e.preventDefault(),e.stopPropagation();else{var t=this.options.zoomOptions&&this.options.zoomOptions.wheel,i=this.options.moveOptions&&this.options.moveOptions.wheel;if(t||i){var n=xs(e);if(Vc)var u=e.metaKey;t&&(e.ctrlKey||u||!i)?(n=-n.y/50,t=_n(e,this.getParentSvg(),this.getInverseScreenCTM()),this.zoom(t.x,t.y,n)):(t=this.scrollX-n.x,i=this.scrollY-n.y,e.shiftKey&&!n.x&&(t=this.scrollX-n.y,i=this.scrollY),this.scroll(t,i)),e.preventDefault()}}}getBlocksBoundingBox(){const e=this.getTopBoundedElements();if(!e.length)return new ct(0,0,0,0);const t=e[0].getBoundingRectangle();for(let n=1;nt.bottom&&(t.bottom=i.bottom),i.leftt.right&&(t.right=i.right))}return t}cleanUp(){this.setResizesEnabled(!1),z(!0);const e=this.getTopBlocks(!0);let t=0;for(let i=0,n;n=e[i];i++){if(!n.isMovable())continue;const u=n.getRelativeToSurfaceXY();n.moveBy(-u.x,t-u.y),n.snapToGrid(),t=n.getRelativeToSurfaceXY().y+n.getHeightWidth().height+this.renderer.getConstants().MIN_BLOCK_HEIGHT}z(!1),this.setResizesEnabled(!0)}showContextMenu(e){if(!this.options.readOnly&&!this.isFlyout){var t=Ye.registry.getContextMenuOptions(Ye.ScopeType.WORKSPACE,{workspace:this});this.configureContextMenu&&this.configureContextMenu(t,e),Zs(e,t,this.RTL)}}updateToolbox(e){if(e=Xs(e)){if(!this.options.languageTree)throw Error("Existing toolbox is null. Can't create new toolbox.");if(_o(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():(v(this),this.getParentSvg().focus({preventScroll:!0}))}zoom(e,t,i){i=Math.pow(this.options.zoomOptions.scaleSpeed,i);const n=this.scale*i;if(this.scale!==n){n>this.options.zoomOptions.maxScale?i=this.options.zoomOptions.maxScale/this.scale:nthis.options.zoomOptions.maxScale?e=this.options.zoomOptions.maxScale:this.options.zoomOptions.minScale&&ei.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)}},ws;(function(e){e.BLOCK="block",e.BUTTON="button"})(ws||(ws={}));var hl=class extends rl{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 _i(e),this.workspace_.setMetricsManager(new hf(this.workspace_,this)),this.workspace_.internalIsFlyout=!0,this.workspace_.setVisible(this.isVisible_),this.id=A(),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_=ee(e,{class:"blocklyFlyout",style:"display: none"}),this.svgBackground_=ee(q.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 Hh(this.workspace_,this.horizontalLayout,!this.horizontalLayout,"blocklyFlyoutScrollbar",this.SCROLLBAR_MARGIN),this.hide(),this.boundEvents.push(ve(this.svgGroup_,"wheel",this,this.wheel_)),this.autoClose||(this.filterWrapper_=this.filterForCapacity_.bind(this),this.targetWorkspace.addChangeListener(this.filterWrapper_)),this.boundEvents.push(ve(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:[Et.Capability.DELETE_AREA,Et.Capability.DRAG_TARGET]})}dispose(){this.hide(),this.workspace_.getComponentManager().removeComponent(this.id);for(const e of this.boundEvents)Je(e);this.boundEvents.length=0,this.filterWrapper_&&(this.targetWorkspace.removeChangeListener(this.filterWrapper_),this.filterWrapper_=null),this.workspace_&&(this.workspace_.getThemeManager().unsubscribe(this.svgBackground_),this.workspace_.dispose()),this.svgGroup_&&(ue(this.svgGroup_),this.svgGroup_=null),this.svgBackground_=null}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,i,n){let u;(u=this.svgGroup_)==null||u.setAttribute("width",`${e}`);let b;(b=this.svgGroup_)==null||b.setAttribute("height",`${t}`),this.workspace_.setCachedParentSvgSize(e,t),this.svgGroup_&&Be(this.svgGroup_,"translate("+i+"px,"+n+"px)"),(e=this.workspace_.scrollbar)&&(e.setOrigin(i,n),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_)Je(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=Ys(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=[],i=[];this.permanentlyDisabled_.length=0;const n=this.horizontalLayout?this.GAP_X:this.GAP_Y;for(const u of e){if("custom"in u){e=this.getDynamicCategoryContents_(u.custom),e=Ys(e);const{contents:b,gaps:G}=this.createFlyoutInfo_(e);t.push(...b),i.push(...G)}switch(u.kind.toUpperCase()){case"BLOCK":e=u;const b=this.createFlyoutBlock_(e);t.push({type:ws.BLOCK,block:b}),this.addBlockGap_(e,i,n);break;case"SEP":this.addSeparatorGap_(u,i,n);break;case"LABEL":e=this.createButton_(u,!0),t.push({type:ws.BUTTON,button:e}),i.push(n);break;case"BUTTON":e=this.createButton_(u,!1),t.push({type:ws.BUTTON,button:e}),i.push(n)}}return{contents:t,gaps:i}}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 mi(this.workspace_,this.targetWorkspace,e,t)}createFlyoutBlock_(e){let t;return e.blockxml?(e=typeof e.blockxml=="string"?De(e.blockxml):e.blockxml,(t=this.getRecycledBlock_(e.getAttribute("type")))||(t=$n(e,this.workspace_))):(t=this.getRecycledBlock_(e.type),t||(e.enabled===void 0&&(e.enabled=e.disabled!=="true"&&e.disabled!==!0),t=qi(e,this.workspace_))),t.isEnabled()||this.permanentlyDisabled_.push(t),t}getRecycledBlock_(e){let t=-1;for(let i=0;i{const i=this.targetWorkspace.getGesture(t);i&&(i.setStartBlock(e),i.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;Q();var i=this.targetWorkspace.getAllVariables();this.targetWorkspace.setResizesEnabled(!1);try{t=this.placeNewBlock_(e)}finally{ie()}if(this.targetWorkspace.hideChaff(),e=Zr(this.targetWorkspace,i),J()){for(z(!0),i=0;i90-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_===Ce.TOP?new ct(-1e9,t+e.height,-1e9,1e9):new ct(t,1e9,-1e9,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=0;const t=this.workspace_.getTopBlocks(!1);for(let n=0,u;u=t[n];n++)e=Math.max(e,u.getHeightWidth().height);const i=this.buttons_;for(let n=0,u;u=i[n];n++)e=Math.max(e,u.height);if(e+=1.5*this.MARGIN,e*=this.workspace_.scale,e+=ot.scrollbarThickness,this.height_!==e){for(let n=0,u;u=t[n];n++)this.rectMap_.has(u)&&this.moveRectToBlock_(this.rectMap_.get(u),u);this.targetWorkspace.toolboxPosition!==this.toolboxPosition_||this.toolboxPosition_!==Ce.TOP||this.targetWorkspace.getToolbox()||this.targetWorkspace.translate(this.targetWorkspace.scrollX,this.targetWorkspace.scrollY+e),this.height_=e,this.position(),this.targetWorkspace.recordDragTargets()}}};m(pe.FLYOUTS_HORIZONTAL_TOOLBOX,Fi,bf);var eu=class extends hl{constructor(e){super(e)}setMetrics_(e){if(this.isVisible()){var t=this.workspace_.getMetricsManager(),i=t.getScrollMetrics(),n=t.getViewMetrics();t=t.getAbsoluteMetrics(),typeof e.y=="number"&&(this.workspace_.scrollY=-(i.top+(i.height-n.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(),i=e.getViewMetrics();return e=e.getToolboxMetrics(),this.targetWorkspace.toolboxPosition===this.toolboxPosition_?this.targetWorkspace.getToolbox()?this.toolboxPosition_===Ce.LEFT?e.width:i.width-this.width_:this.toolboxPosition_===Ce.LEFT?0:i.width:this.toolboxPosition_===Ce.LEFT?0:i.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 i=this.toolboxPosition_===Ce.RIGHT;var n=e+this.CORNER_RADIUS;n=["M "+(i?n:0)+",0"],n.push("h",i?-e:e),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,i?0:1,i?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),n.push("v",Math.max(0,t)),n.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,i?0:1,i?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),n.push("h",i?e:-e),n.push("z"),this.svgBackground_.setAttribute("d",n.join(" "))}scrollToStart(){let e;(e=this.workspace_.scrollbar)==null||e.setY(0)}wheel_(e){var t=xs(e);if(t.y){const i=this.workspace_.getMetricsManager(),n=i.getScrollMetrics();t=i.getViewMetrics().top-n.top+t.y;let u;(u=this.workspace_.scrollbar)==null||u.setY(t),li(),oi()}e.preventDefault(),e.stopPropagation()}layout_(e,t){this.workspace_.scale=this.targetWorkspace.scale;var i=this.MARGIN;const n=this.RTL?i:i+this.tabWidth_;for(let X=0,re;re=e[X];X++)if(re.type==="block"){var u=re.block,b=u.getDescendants(!1);for(let lt=0,at;at=b[lt];lt++)at.isInFlyout=!0;u.render(),b=u.getSvgRoot();const me=u.getHeightWidth();var G=u.outputConnection?n-this.tabWidth_:n;u.moveBy(G,i),G=this.createRect_(u,this.RTL?G-me.width:G,i,me,X),this.addBlockListeners_(b,u,G),i+=me.height+t[X]}else re.type==="button"&&(u=re.button,this.initFlyoutButton_(u,n,i),i+=u.height+t[X])}isDragTowardWorkspace(e){e=Math.atan2(e.y,e.x)/Math.PI*180;const t=this.dragAngleRange_;return 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_===Ce.LEFT?new ct(-1e9,1e9,-1e9,t+e.width):new ct(-1e9,1e9,t,1e9)}reflowInternal_(){this.workspace_.scale=this.getFlyoutScale();let e=0;var t=this.workspace_.getTopBlocks(!1);for(let n=0,u;u=t[n];n++){var i=u.getHeightWidth().width;u.outputConnection&&(i-=this.tabWidth_),e=Math.max(e,i)}for(let n=0,u;u=this.buttons_[n];n++)e=Math.max(e,u.width);if(e+=1.5*this.MARGIN+this.tabWidth_,e*=this.workspace_.scale,e+=ot.scrollbarThickness,this.width_!==e){for(let n=0,u;u=t[n];n++){if(this.RTL){i=u.getRelativeToSurfaceXY().x;let b=e/this.workspace_.scale-this.MARGIN;u.outputConnection||(b-=this.tabWidth_),u.moveBy(b-i,0)}this.rectMap_.has(u)&&this.moveRectToBlock_(this.rectMap_.get(u),u)}if(this.RTL)for(let n=0,u;u=this.buttons_[n];n++)t=u.getPosition().y,u.moveTo(e/this.workspace_.scale-u.width-this.MARGIN-this.tabWidth_,t);this.targetWorkspace.toolboxPosition!==this.toolboxPosition_||this.toolboxPosition_!==Ce.LEFT||this.targetWorkspace.getToolbox()||this.targetWorkspace.translate(this.targetWorkspace.scrollX+e,this.targetWorkspace.scrollY),this.width_=e,this.position(),this.targetWorkspace.recordDragTargets()}}};eu.registryName="verticalFlyout",m(pe.FLYOUTS_VERTICAL_TOOLBOX,Fi,eu),s.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=_());var t=[];this.init(e),e=e.getTopBlocks(!0);for(let i=0,n;n=e[i];i++){let u=this.blockToCode(n);Array.isArray(u)&&(u=u[0]),u&&(n.outputConnection&&(u=this.scrubNakedValue(u),this.STATEMENT_PREFIX&&!n.suppressPrefixSuffix&&(u=this.injectId(this.STATEMENT_PREFIX,n)+u),this.STATEMENT_SUFFIX&&!n.suppressPrefixSuffix&&(u+=this.injectId(this.STATEMENT_SUFFIX,n))),t.push(u))}return t=t.join(` `),t=this.finish(t),t=t.replace(/^\s+\n/,""),t=t.replace(/\n\s+$/,` `),t=t.replace(/[ \t]+\n/g,` `)}prefixLines(e,t){return t+e.replace(/(?!\n$)\n/g,` `+t)}allNestedComments(e){const t=[];e=e.getDescendants(!0);for(let i=0;i.blocklyPathLight,`,`${e} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},Rf=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_+` -`+this.inlineSteps_}drawTopCorner(e){this.steps_+=tt(e.xPos,this.info_.startY);for(let t=0,i;i=e.elements[t];t++)Z.isLeftSquareCorner(i)?this.steps_+=this.highlightConstants_.START_POINT:Z.isLeftRoundedCorner(i)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):Z.isPreviousConnection(i)?this.steps_+=this.notchPaths_.pathLeft:Z.isHat(i)?this.steps_+=this.startPaths_.path(this.RTL_):Z.isSpacer(i)&&i.width!==0&&(this.steps_+=_e("H",i.xPos+i.width-this.highlightOffset_));this.steps_+=_e("H",e.xPos+e.width-this.highlightOffset_)}drawJaggedEdge_(e){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+_e("v",e.height-this.jaggedTeethPaths_.height-this.highlightOffset_))}drawValueInput(e){const t=e.getLastInput();if(this.RTL_){const i=e.height-t.connectionHeight;this.steps_+=yt(t.xPos+t.width-this.highlightOffset_,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+_e("v",i)}else this.steps_+=yt(t.xPos+t.width,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(e){const t=e.getLastInput();if(t)if(this.RTL_){const i=e.height-2*this.insideCornerPaths_.height;this.steps_+=yt(t.xPos,e.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+_e("v",i)+this.insideCornerPaths_.pathBottom(this.RTL_)+Ii(e.width-t.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=yt(t.xPos,e.yPos+e.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+Ii(e.width-t.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(e){const t=e.xPos+e.width-this.highlightOffset_;e instanceof jh&&e.followsStatement&&(this.steps_+=_e("H",t)),this.RTL_&&(this.steps_+=_e("H",t),e.height>this.highlightOffset_&&(this.steps_+=_e("V",e.yPos+e.height-this.highlightOffset_)))}drawBottomRow(e){if(this.RTL_)this.steps_+=_e("V",e.baseline-this.highlightOffset_);else{const t=this.info_.bottomRow.elements[0];Z.isLeftSquareCorner(t)?this.steps_+=yt(e.xPos+this.highlightOffset_,e.baseline-this.highlightOffset_):Z.isLeftRoundedCorner(t)&&(this.steps_+=yt(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_+=yt(this.info_.startX,e):(this.steps_+=yt(this.info_.startX+this.highlightOffset_,this.info_.bottomRow.baseline-this.highlightOffset_),this.steps_+=_e("V",e)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(e=this.info_.topRow,Z.isLeftRoundedCorner(e.elements[0])?this.steps_+=_e("V",this.outsideCornerPaths_.height):this.steps_+=_e("V",e.capline+this.highlightOffset_))}drawInlineInput(e){const t=this.highlightOffset_,i=e.xPos+e.connectionWidth;var n=e.centerline-e.height/2;const u=e.width-e.connectionWidth,E=n+t;this.RTL_?(n=e.connectionOffsetY-t,e=e.height-(e.connectionOffsetY+e.connectionHeight)+t,this.inlineSteps_+=yt(i-t,E)+_e("v",n)+this.puzzleTabPaths_.pathDown(this.RTL_)+_e("v",e)+_e("h",u)):this.inlineSteps_+=yt(e.xPos+e.width+t,E)+_e("v",e.height)+_e("h",-u)+yt(i,n+e.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},Cf=class extends xr{constructor(e,t){super(e,t),this.highlighter_=new Rf(t)}draw(){this.hideHiddenIcons_(),this.drawOutline_(),this.drawInternals_();const e=this.block_.pathObject;if(e.setPath(this.outlinePath_+` -`+this.inlinePath_),e.setHighlightPath(this.highlighter_.getPath()),this.info_.RTL&&e.flipRTL(),tr()){let t,i;(t=this.block_)==null||(i=t.renderingDebugger)==null||i.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_+=_e("H",e.xPos+e.width)+_e("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 i=e.xPos+e.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(i*=-1),e.connectionModel.setOffsetInBlock(i,t+e.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(e){const t=e.getLastInput();if(t!=null&&t.connectionModel){let i=e.xPos+e.statementEdge+t.notchOffset;i=this.info_.RTL?-1*i:i+this.constants_.DARK_PATH_OFFSET,t.connectionModel.setOffsetInBlock(i,e.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(e){const t=e.getLastInput();if(t&&t.connectionModel){let i=e.xPos+e.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(i*=-1),t.connectionModel.setOffsetInBlock(i,e.yPos)}}positionNextConnection_(){const e=this.info_.bottomRow;if(e.connection){const t=e.connection,i=t.xPos;t.connectionModel.setOffsetInBlock((this.info_.RTL?-i:i)+this.constants_.DARK_PATH_OFFSET/2,e.baseline+this.constants_.DARK_PATH_OFFSET)}}},kf=class{constructor(e){this.OFFSET=.5,this.constantProvider=e,this.START_POINT=tt(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,i=(1-Math.SQRT1_2)*(e+t)-t,n=tt(i,i)+ht("a","0 0,0",e,Ee(-i-t,e-i)),u=ht("a","0 0,0",e+t,Ee(e+t,e+t)),E=tt(i,-i)+ht("a","0 0,0",e+t,Ee(e-i,i+t));return{width:e+t,height:e,pathTop(G){return G?n:""},pathBottom(G){return G?u:E}}}makeOutsideCorner(){const e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,i=(1-Math.SQRT1_2)*(e-t)+t,n=tt(i,i)+ht("a","0 0,1",e-t,Ee(e-i,-i+t)),u=tt(t,e)+ht("a","0 0,1",e-t,Ee(e,-e+t)),E=-i,G=tt(i,E)+ht("a","0 0,1",e-t,Ee(-i+t,-E-e));return{height:e,topLeft(X){return X?n:u},bottomLeft(){return G}}}makePuzzleTab(){const e=this.constantProvider.TAB_WIDTH,t=this.constantProvider.TAB_HEIGHT,i=tt(-2,-t+3.4)+Ii(-.45*e,-2.1),n=_e("v",2.5)+tt(.97*-e,2.5)+Ft("q",[Ee(.05*-e,10),Ee(.3*e,9.5)])+tt(.67*e,-1.9)+_e("v",2.5),u=_e("v",-1.5)+tt(-.92*e,-.5)+Ft("q",[Ee(-.19*e,-5.5),Ee(0,-11)])+tt(.92*e,1),E=tt(-5,t-.7)+Ii(.46*e,-2.1);return{width:e,height:t,pathUp(G){return G?i:u},pathDown(G){return G?n:E}}}makeNotch(){return{pathLeft:_e("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:Ii(5.1,2.6)+tt(-10.2,6.8)+Ii(5.1,2.6),height:12,width:10.2}}makeStartHat(){const e=this.constantProvider.START_HAT.height,t=tt(25,-8.7)+Ft("c",[Ee(29.7,-6.2),Ee(57.2,-.5),Ee(75,8.7)]),i=Ft("c",[Ee(17.8,-9.2),Ee(45.3,-14.9),Ee(75,-8.7)])+yt(100.5,e+.5);return{path(n){return n?t:i}}}},Af=class extends Yh{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)}},Of=class extends Lr{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Lf=class extends Es{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===Ae.STATEMENT||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(e,t){this.isInline&&e.type===Ae.VALUE?(t.elements.push(new Af(this.constants_,e)),t.hasInlineInput=!0):e.type===Ae.STATEMENT?(t.elements.push(new Of(this.constants_,e)),t.hasStatement=!0):e.type===Ae.VALUE?(t.elements.push(new al(this.constants_,e)),t.hasExternalInput=!0):e.type===Ae.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 i=0,n;n=this.rows[i];i++)n.hasExternalInput&&(e=!0);for(let i=0,n;n=this.rows[i];i++){var t=n.elements;if(n.elements=[],n.startsWithElemSpacer()&&n.elements.push(new Jt(this.constants_,this.getInRowSpacing_(null,t[0]))),t.length){for(let u=0;ut?t:E,u=u?-1:1,i=(n?-1:1)*i/2,Ii(-u*E,i)+Ii(u*E,i)}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width(i){return i/=2,i>t?t:i},height(i){return i},connectionOffsetY(i){return i/2},connectionOffsetX(i){return-i},pathDown(i){return e(i,!1,!1)},pathUp(i){return e(i,!0,!1)},pathRightDown(i){return e(i,!1,!0)},pathRightUp(i){return e(i,!1,!0)}}}makeRounded(){function e(n,u,E){const G=n>i?n-i:0;return n=(n>i?i:n)/2,ht("a","0 0,1",n,Ee((u?-1:1)*n,(u?-1:1)*n))+_e("v",(E?1:-1)*G)+ht("a","0 0,1",n,Ee((u?1:-1)*n,(u?-1:1)*n))}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,i=2*t;return{type:this.SHAPES.ROUND,isDynamic:!0,width(n){return n/=2,n>t?t:n},height(n){return n},connectionOffsetY(n){return n/2},connectionOffsetX(n){return-n},pathDown(n){return e(n,!1,!1)},pathUp(n){return e(n,!0,!1)},pathRightDown(n){return e(n,!1,!0)},pathRightUp(n){return e(n,!1,!0)}}}makeSquared(){function e(i,n,u){return i-=2*t,ht("a","0 0,1",t,Ee((n?-1:1)*t,(n?-1:1)*t))+_e("v",(u?1:-1)*i)+ht("a","0 0,1",t,Ee((n?1:-1)*t,(n?-1:1)*t))}const t=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width(i){return t},height(i){return i},connectionOffsetY(i){return i/2},connectionOffsetX(i){return-i},pathDown(i){return e(i,!1,!1)},pathUp(i){return e(i,!0,!1)},pathRightDown(i){return e(i,!1,!0)},pathRightUp(i){return e(i,!1,!0)}}}shapeFor(e){let t=e.getCheck();switch(!t&&e.targetConnection&&(t=e.targetConnection.getCheck()),e.type){case $e.INPUT_VALUE:case $e.OUTPUT_VALUE:if(e=e.getSourceBlock().getOutputShape(),e!==null)switch(e){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}return t&&t.indexOf("Boolean")!==-1?this.HEXAGONAL:t&&t.indexOf("Number")!==-1?this.ROUNDED:(t&&t.indexOf("String"),this.ROUNDED);case $e.PREVIOUS_STATEMENT:case $e.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}makeNotch(){function e(me){return Ft("c",[Ee(me*u/2,0),Ee(me*u*3/4,G/2),Ee(me*u,G)])+Jn([Ee(me*u,E)])+Ft("c",[Ee(me*u/4,G/2),Ee(me*u/2,G),Ee(me*u,G)])+_e("h",me*n)+Ft("c",[Ee(me*u/2,0),Ee(me*u*3/4,-(G/2)),Ee(me*u,-G)])+Jn([Ee(me*u,-E)])+Ft("c",[Ee(me*u/4,-(G/2)),Ee(me*u/2,-G),Ee(me*u,-G)])}const t=this.NOTCH_WIDTH,i=this.NOTCH_HEIGHT,n=t/3,u=n/3,E=i/2,G=E/2,X=e(1),re=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:i,pathLeft:X,pathRight:re}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=ht("a","0 0,0",e,Ee(-e,e)),i=ht("a","0 0,1",e,Ee(-e,e)),n=ht("a","0 0,0",e,Ee(e,e)),u=ht("a","0 0,1",e,Ee(e,e));return{width:e,height:e,pathTop:t,pathBottom:n,rightWidth:e,rightHeight:e,pathTopRight:i,pathBottomRight:u}}generateSecondaryColour_(e){return $n("#000",e,.15)||e}generateTertiaryColour_(e){return $n("#000",e,.25)||e}createDom(e,t,i){super.createDom(e,t,i),e=ee(q.DEFS,{},e),t=ee(q.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),ee(q.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},t),i=ee(q.FECOMPONENTTRANSFER,{result:"outBlur"},t),ee(q.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},i),ee(q.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),ee(q.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),this.selectedGlowFilterId=t.id,this.selectedGlowFilter_=t,e=ee(q.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),ee(q.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},e),t=ee(q.FECOMPONENTTRANSFER,{result:"outBlur"},e),ee(q.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),ee(q.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),ee(q.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),ee(q.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;","}"]}},Hf=class extends xr{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_+` -`+this.inlinePath_),this.info_.RTL&&e.flipRTL(),tr()){let t,i;(t=this.block_)==null||(i=t.renderingDebugger)==null||i.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(Z.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=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!n.precedesStatement,Z.isInputRow(E)&&E.hasStatement){E.measure();let G,X;t=E.width-((X=(G=E.getLastInput())==null?void 0:G.width)!=null?X:0)+e}else if(i&&(u===2||n)&&Z.isInputRow(E)&&!E.hasStatement){n=E.xPos,i=null;for(let G=0;Gi?i:this.height/2,t-i*(1-Math.sin(Math.acos((i-this.constants_.SMALL_PADDING)/i)));default:return 0}if(Z.isInlineInput(e)&&e instanceof Yi){const u=e.connectedBlock;return e=u?u.pathObject.outputShapeType:e.shape.type,e==null||u&&u.outputConnection&&(u.statementInputCount||u.nextConnection)||i===n.SHAPES.HEXAGONAL&&i!==e?0:t-this.constants_.SHAPE_IN_SHAPE_PADDING[i][e]}return Z.isField(e)&&e instanceof xn?i===n.SHAPES.ROUND&&e.field instanceof Ts?t-2.75*n.GRID_UNIT:t-this.constants_.SHAPE_IN_SHAPE_PADDING[i][0]:Z.isIcon(e)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let n=2;n=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!G.precedesStatement;if(e?this.topRow.hasPreviousConnection:u.followsStatement){var i=E.elements[1];if(i=E.elements.length===3&&i instanceof xn&&(i.field instanceof hn||i.field instanceof Nn),!e&&i)u.height-=this.constants_.SMALL_PADDING,G.height-=this.constants_.SMALL_PADDING,E.height-=this.constants_.MEDIUM_PADDING;else if(!e&&!t)u.height+=this.constants_.SMALL_PADDING;else if(t){for(e=!1,t=0;t_c(t)),e.length?e:null}load(e,t){const i=t.getProcedureMap();for(const n of e)i.add(vc(this.procedureModelClass,this.parameterModelClass,n,t))}clear(e){e.getProcedureMap().clear()}},ws={};ws.ProcedureSerializer=o_,ws.loadParameter=Tc,ws.loadProcedure=vc,ws.saveParameter=$c,ws.saveProcedure=_c;var Zf=class{constructor(){this.priority=Mg}save(e){const t=[];for(const i of e.getAllVariables())e={name:i.name,id:i.getId()},i.type&&(e.type=i.type),t.push(e);return t.length?t:null}load(e,t){for(const i of e)t.createVariable(i.name,i.type,i.id)}clear(e){e.getVariableMap().clear()}};io("variables",new Zf);var Qf={};Qf.VariableSerializer=Zf;var iu={};iu.load=xp,iu.save=Dp;var l_={blocks:gr,exceptions:ls,priorities:Xo,procedures:ws,registry:Kc,variables:Qf,workspaces:iu},Me;(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"})(Me||(Me={}));var Di;(function(e){e.ESCAPE="escape",e.DELETE="delete",e.COPY="copy",e.CUT="cut",e.PASTE="paste",e.UNDO="undo",e.REDO="redo"})(Di||(Di={})),Cc();var xi={};xi.names=Di,xi.registerCopy=yc,xi.registerCut=wc,xi.registerDefaultShortcuts=Cc,xi.registerDelete=bc,xi.registerEscape=Ec,xi.registerPaste=Sc,xi.registerRedo=Rc,xi.registerUndo=Ic;var a_={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"}},c_={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"}},h_=new On("zelos",a_,c_),nu={};nu.Classic=tl,nu.Zelos=h_;var su=class{constructor(e,t,i){this.id_=e.toolboxitemid||F(),this.level_=(this.parent_=i||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){}},vi=class extends su{constructor(e,t,i){super(e,t,i),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.blocklyPathLight,`,`${e} .blocklyInsertionMarker>.blocklyPathDark {`,`fill-opacity: ${this.INSERTION_MARKER_OPACITY};`,"stroke: none;","}"])}},If=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_+` +`+this.inlineSteps_}drawTopCorner(e){this.steps_+=tt(e.xPos,this.info_.startY);for(let t=0,i;i=e.elements[t];t++)Z.isLeftSquareCorner(i)?this.steps_+=this.highlightConstants_.START_POINT:Z.isLeftRoundedCorner(i)?this.steps_+=this.outsideCornerPaths_.topLeft(this.RTL_):Z.isPreviousConnection(i)?this.steps_+=this.notchPaths_.pathLeft:Z.isHat(i)?this.steps_+=this.startPaths_.path(this.RTL_):Z.isSpacer(i)&&i.width!==0&&(this.steps_+=_e("H",i.xPos+i.width-this.highlightOffset_));this.steps_+=_e("H",e.xPos+e.width-this.highlightOffset_)}drawJaggedEdge_(e){this.info_.RTL&&(this.steps_+=this.jaggedTeethPaths_.pathLeft+_e("v",e.height-this.jaggedTeethPaths_.height-this.highlightOffset_))}drawValueInput(e){const t=e.getLastInput();if(this.RTL_){const i=e.height-t.connectionHeight;this.steps_+=yt(t.xPos+t.width-this.highlightOffset_,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)+_e("v",i)}else this.steps_+=yt(t.xPos+t.width,e.yPos)+this.puzzleTabPaths_.pathDown(this.RTL_)}drawStatementInput(e){const t=e.getLastInput();if(t)if(this.RTL_){const i=e.height-2*this.insideCornerPaths_.height;this.steps_+=yt(t.xPos,e.yPos)+this.insideCornerPaths_.pathTop(this.RTL_)+_e("v",i)+this.insideCornerPaths_.pathBottom(this.RTL_)+Ii(e.width-t.xPos-this.insideCornerPaths_.width,0)}else this.steps_+=yt(t.xPos,e.yPos+e.height)+this.insideCornerPaths_.pathBottom(this.RTL_)+Ii(e.width-t.xPos-this.insideCornerPaths_.width,0)}drawRightSideRow(e){const t=e.xPos+e.width-this.highlightOffset_;e instanceof jh&&e.followsStatement&&(this.steps_+=_e("H",t)),this.RTL_&&(this.steps_+=_e("H",t),e.height>this.highlightOffset_&&(this.steps_+=_e("V",e.yPos+e.height-this.highlightOffset_)))}drawBottomRow(e){if(this.RTL_)this.steps_+=_e("V",e.baseline-this.highlightOffset_);else{const t=this.info_.bottomRow.elements[0];Z.isLeftSquareCorner(t)?this.steps_+=yt(e.xPos+this.highlightOffset_,e.baseline-this.highlightOffset_):Z.isLeftRoundedCorner(t)&&(this.steps_+=yt(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_+=yt(this.info_.startX,e):(this.steps_+=yt(this.info_.startX+this.highlightOffset_,this.info_.bottomRow.baseline-this.highlightOffset_),this.steps_+=_e("V",e)),this.steps_+=this.puzzleTabPaths_.pathUp(this.RTL_)),this.RTL_||(e=this.info_.topRow,Z.isLeftRoundedCorner(e.elements[0])?this.steps_+=_e("V",this.outsideCornerPaths_.height):this.steps_+=_e("V",e.capline+this.highlightOffset_))}drawInlineInput(e){const t=this.highlightOffset_,i=e.xPos+e.connectionWidth;var n=e.centerline-e.height/2;const u=e.width-e.connectionWidth,b=n+t;this.RTL_?(n=e.connectionOffsetY-t,e=e.height-(e.connectionOffsetY+e.connectionHeight)+t,this.inlineSteps_+=yt(i-t,b)+_e("v",n)+this.puzzleTabPaths_.pathDown(this.RTL_)+_e("v",e)+_e("h",u)):this.inlineSteps_+=yt(e.xPos+e.width+t,b)+_e("v",e.height)+_e("h",-u)+yt(i,n+e.connectionOffsetY)+this.puzzleTabPaths_.pathDown(this.RTL_)}},Rf=class extends xr{constructor(e,t){super(e,t),this.highlighter_=new If(t)}draw(){this.hideHiddenIcons_(),this.drawOutline_(),this.drawInternals_();const e=this.block_.pathObject;if(e.setPath(this.outlinePath_+` +`+this.inlinePath_),e.setHighlightPath(this.highlighter_.getPath()),this.info_.RTL&&e.flipRTL(),tr()){let t,i;(t=this.block_)==null||(i=t.renderingDebugger)==null||i.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_+=_e("H",e.xPos+e.width)+_e("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 i=e.xPos+e.connectionWidth+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(i*=-1),e.connectionModel.setOffsetInBlock(i,t+e.connectionOffsetY+this.constants_.DARK_PATH_OFFSET)}}positionStatementInputConnection_(e){const t=e.getLastInput();if(t!=null&&t.connectionModel){let i=e.xPos+e.statementEdge+t.notchOffset;i=this.info_.RTL?-1*i:i+this.constants_.DARK_PATH_OFFSET,t.connectionModel.setOffsetInBlock(i,e.yPos+this.constants_.DARK_PATH_OFFSET)}}positionExternalValueConnection_(e){const t=e.getLastInput();if(t&&t.connectionModel){let i=e.xPos+e.width+this.constants_.DARK_PATH_OFFSET;this.info_.RTL&&(i*=-1),t.connectionModel.setOffsetInBlock(i,e.yPos)}}positionNextConnection_(){const e=this.info_.bottomRow;if(e.connection){const t=e.connection,i=t.xPos;t.connectionModel.setOffsetInBlock((this.info_.RTL?-i:i)+this.constants_.DARK_PATH_OFFSET/2,e.baseline+this.constants_.DARK_PATH_OFFSET)}}},Cf=class{constructor(e){this.OFFSET=.5,this.constantProvider=e,this.START_POINT=tt(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,i=(1-Math.SQRT1_2)*(e+t)-t,n=tt(i,i)+ht("a","0 0,0",e,Ee(-i-t,e-i)),u=ht("a","0 0,0",e+t,Ee(e+t,e+t)),b=tt(i,-i)+ht("a","0 0,0",e+t,Ee(e-i,i+t));return{width:e+t,height:e,pathTop(G){return G?n:""},pathBottom(G){return G?u:b}}}makeOutsideCorner(){const e=this.constantProvider.CORNER_RADIUS,t=this.OFFSET,i=(1-Math.SQRT1_2)*(e-t)+t,n=tt(i,i)+ht("a","0 0,1",e-t,Ee(e-i,-i+t)),u=tt(t,e)+ht("a","0 0,1",e-t,Ee(e,-e+t)),b=-i,G=tt(i,b)+ht("a","0 0,1",e-t,Ee(-i+t,-b-e));return{height:e,topLeft(X){return X?n:u},bottomLeft(){return G}}}makePuzzleTab(){const e=this.constantProvider.TAB_WIDTH,t=this.constantProvider.TAB_HEIGHT,i=tt(-2,-t+3.4)+Ii(-.45*e,-2.1),n=_e("v",2.5)+tt(.97*-e,2.5)+Ft("q",[Ee(.05*-e,10),Ee(.3*e,9.5)])+tt(.67*e,-1.9)+_e("v",2.5),u=_e("v",-1.5)+tt(-.92*e,-.5)+Ft("q",[Ee(-.19*e,-5.5),Ee(0,-11)])+tt(.92*e,1),b=tt(-5,t-.7)+Ii(.46*e,-2.1);return{width:e,height:t,pathUp(G){return G?i:u},pathDown(G){return G?n:b}}}makeNotch(){return{pathLeft:_e("h",this.OFFSET)+this.constantProvider.NOTCH.pathLeft}}makeJaggedTeeth(){return{pathLeft:Ii(5.1,2.6)+tt(-10.2,6.8)+Ii(5.1,2.6),height:12,width:10.2}}makeStartHat(){const e=this.constantProvider.START_HAT.height,t=tt(25,-8.7)+Ft("c",[Ee(29.7,-6.2),Ee(57.2,-.5),Ee(75,8.7)]),i=Ft("c",[Ee(17.8,-9.2),Ee(45.3,-14.9),Ee(75,-8.7)])+yt(100.5,e+.5);return{path(n){return n?t:i}}}},Af=class extends Yh{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)}},kf=class extends Lr{constructor(e,t){super(e,t),this.constants_=e,this.connectedBlock&&(this.height+=this.constants_.DARK_PATH_OFFSET)}},Of=class extends bs{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===ke.STATEMENT||(this.bottomRow.minHeight=this.constants_.MEDIUM_PADDING-this.constants_.DARK_PATH_OFFSET)}addInput_(e,t){this.isInline&&e.type===ke.VALUE?(t.elements.push(new Af(this.constants_,e)),t.hasInlineInput=!0):e.type===ke.STATEMENT?(t.elements.push(new kf(this.constants_,e)),t.hasStatement=!0):e.type===ke.VALUE?(t.elements.push(new al(this.constants_,e)),t.hasExternalInput=!0):e.type===ke.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 i=0,n;n=this.rows[i];i++)n.hasExternalInput&&(e=!0);for(let i=0,n;n=this.rows[i];i++){var t=n.elements;if(n.elements=[],n.startsWithElemSpacer()&&n.elements.push(new Zt(this.constants_,this.getInRowSpacing_(null,t[0]))),t.length){for(let u=0;ut?t:b,u=u?-1:1,i=(n?-1:1)*i/2,Ii(-u*b,i)+Ii(u*b,i)}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH;return{type:this.SHAPES.HEXAGONAL,isDynamic:!0,width(i){return i/=2,i>t?t:i},height(i){return i},connectionOffsetY(i){return i/2},connectionOffsetX(i){return-i},pathDown(i){return e(i,!1,!1)},pathUp(i){return e(i,!0,!1)},pathRightDown(i){return e(i,!1,!0)},pathRightUp(i){return e(i,!1,!0)}}}makeRounded(){function e(n,u,b){const G=n>i?n-i:0;return n=(n>i?i:n)/2,ht("a","0 0,1",n,Ee((u?-1:1)*n,(u?-1:1)*n))+_e("v",(b?1:-1)*G)+ht("a","0 0,1",n,Ee((u?1:-1)*n,(u?-1:1)*n))}const t=this.MAX_DYNAMIC_CONNECTION_SHAPE_WIDTH,i=2*t;return{type:this.SHAPES.ROUND,isDynamic:!0,width(n){return n/=2,n>t?t:n},height(n){return n},connectionOffsetY(n){return n/2},connectionOffsetX(n){return-n},pathDown(n){return e(n,!1,!1)},pathUp(n){return e(n,!0,!1)},pathRightDown(n){return e(n,!1,!0)},pathRightUp(n){return e(n,!1,!0)}}}makeSquared(){function e(i,n,u){return i-=2*t,ht("a","0 0,1",t,Ee((n?-1:1)*t,(n?-1:1)*t))+_e("v",(u?1:-1)*i)+ht("a","0 0,1",t,Ee((n?1:-1)*t,(n?-1:1)*t))}const t=this.CORNER_RADIUS;return{type:this.SHAPES.SQUARE,isDynamic:!0,width(i){return t},height(i){return i},connectionOffsetY(i){return i/2},connectionOffsetX(i){return-i},pathDown(i){return e(i,!1,!1)},pathUp(i){return e(i,!0,!1)},pathRightDown(i){return e(i,!1,!0)},pathRightUp(i){return e(i,!1,!0)}}}shapeFor(e){let t=e.getCheck();switch(!t&&e.targetConnection&&(t=e.targetConnection.getCheck()),e.type){case $e.INPUT_VALUE:case $e.OUTPUT_VALUE:if(e=e.getSourceBlock().getOutputShape(),e!==null)switch(e){case this.SHAPES.HEXAGONAL:return this.HEXAGONAL;case this.SHAPES.ROUND:return this.ROUNDED;case this.SHAPES.SQUARE:return this.SQUARED}return t&&t.indexOf("Boolean")!==-1?this.HEXAGONAL:t&&t.indexOf("Number")!==-1?this.ROUNDED:(t&&t.indexOf("String"),this.ROUNDED);case $e.PREVIOUS_STATEMENT:case $e.NEXT_STATEMENT:return this.NOTCH;default:throw Error("Unknown type")}}makeNotch(){function e(me){return Ft("c",[Ee(me*u/2,0),Ee(me*u*3/4,G/2),Ee(me*u,G)])+Zn([Ee(me*u,b)])+Ft("c",[Ee(me*u/4,G/2),Ee(me*u/2,G),Ee(me*u,G)])+_e("h",me*n)+Ft("c",[Ee(me*u/2,0),Ee(me*u*3/4,-(G/2)),Ee(me*u,-G)])+Zn([Ee(me*u,-b)])+Ft("c",[Ee(me*u/4,-(G/2)),Ee(me*u/2,-G),Ee(me*u,-G)])}const t=this.NOTCH_WIDTH,i=this.NOTCH_HEIGHT,n=t/3,u=n/3,b=i/2,G=b/2,X=e(1),re=e(-1);return{type:this.SHAPES.NOTCH,width:t,height:i,pathLeft:X,pathRight:re}}makeInsideCorners(){const e=this.CORNER_RADIUS,t=ht("a","0 0,0",e,Ee(-e,e)),i=ht("a","0 0,1",e,Ee(-e,e)),n=ht("a","0 0,0",e,Ee(e,e)),u=ht("a","0 0,1",e,Ee(e,e));return{width:e,height:e,pathTop:t,pathBottom:n,rightWidth:e,rightHeight:e,pathTopRight:i,pathBottomRight:u}}generateSecondaryColour_(e){return vn("#000",e,.15)||e}generateTertiaryColour_(e){return vn("#000",e,.25)||e}createDom(e,t,i){super.createDom(e,t,i),e=ee(q.DEFS,{},e),t=ee(q.FILTER,{id:"blocklySelectedGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),ee(q.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.SELECTED_GLOW_SIZE},t),i=ee(q.FECOMPONENTTRANSFER,{result:"outBlur"},t),ee(q.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},i),ee(q.FEFLOOD,{"flood-color":this.SELECTED_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},t),ee(q.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},t),this.selectedGlowFilterId=t.id,this.selectedGlowFilter_=t,e=ee(q.FILTER,{id:"blocklyReplacementGlowFilter"+this.randomIdentifier,height:"160%",width:"180%",y:"-30%",x:"-40%"},e),ee(q.FEGAUSSIANBLUR,{in:"SourceGraphic",stdDeviation:this.REPLACEMENT_GLOW_SIZE},e),t=ee(q.FECOMPONENTTRANSFER,{result:"outBlur"},e),ee(q.FEFUNCA,{type:"table",tableValues:"0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"},t),ee(q.FEFLOOD,{"flood-color":this.REPLACEMENT_GLOW_COLOUR,"flood-opacity":1,result:"outColor"},e),ee(q.FECOMPOSITE,{in:"outColor",in2:"outBlur",operator:"in",result:"outGlow"},e),ee(q.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;","}"]}},Uf=class extends xr{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_+` +`+this.inlinePath_),this.info_.RTL&&e.flipRTL(),tr()){let t,i;(t=this.block_)==null||(i=t.renderingDebugger)==null||i.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(Z.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=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!n.precedesStatement,Z.isInputRow(b)&&b.hasStatement){b.measure();let G,X;t=b.width-((X=(G=b.getLastInput())==null?void 0:G.width)!=null?X:0)+e}else if(i&&(u===2||n)&&Z.isInputRow(b)&&!b.hasStatement){n=b.xPos,i=null;for(let G=0;Gi?i:this.height/2,t-i*(1-Math.sin(Math.acos((i-this.constants_.SMALL_PADDING)/i)));default:return 0}if(Z.isInlineInput(e)&&e instanceof Yi){const u=e.connectedBlock;return e=u?u.pathObject.outputShapeType:e.shape.type,e==null||u&&u.outputConnection&&(u.statementInputCount||u.nextConnection)||i===n.SHAPES.HEXAGONAL&&i!==e?0:t-this.constants_.SHAPE_IN_SHAPE_PADDING[i][e]}return Z.isField(e)&&e instanceof Bn?i===n.SHAPES.ROUND&&e.field instanceof Es?t-2.75*n.GRID_UNIT:t-this.constants_.SHAPE_IN_SHAPE_PADDING[i][0]:Z.isIcon(e)?this.constants_.SMALL_PADDING:0}finalizeVerticalAlignment_(){if(!this.outputConnection)for(let n=2;n=this.rows.length-1?!!this.bottomRow.hasNextConnection:!!G.precedesStatement;if(e?this.topRow.hasPreviousConnection:u.followsStatement){var i=b.elements[1];if(i=b.elements.length===3&&i instanceof Bn&&(i.field instanceof hn||i.field instanceof Dn),!e&&i)u.height-=this.constants_.SMALL_PADDING,G.height-=this.constants_.SMALL_PADDING,b.height-=this.constants_.MEDIUM_PADDING;else if(!e&&!t)u.height+=this.constants_.SMALL_PADDING;else if(t){for(e=!1,t=0;t_c(t)),e.length?e:null}load(e,t){const i=t.getProcedureMap();for(const n of e)i.add(vc(this.procedureModelClass,this.parameterModelClass,n,t))}clear(e){e.getProcedureMap().clear()}},Ss={};Ss.ProcedureSerializer=o_,Ss.loadParameter=Tc,Ss.loadProcedure=vc,Ss.saveParameter=$c,Ss.saveProcedure=_c;var Jf=class{constructor(){this.priority=Lg}save(e){const t=[];for(const i of e.getAllVariables())e={name:i.name,id:i.getId()},i.type&&(e.type=i.type),t.push(e);return t.length?t:null}load(e,t){for(const i of e)t.createVariable(i.name,i.type,i.id)}clear(e){e.getVariableMap().clear()}};io("variables",new Jf);var Zf={};Zf.VariableSerializer=Jf;var iu={};iu.load=Dp,iu.save=Np;var l_={blocks:gr,exceptions:as,priorities:Xo,procedures:Ss,registry:Kc,variables:Zf,workspaces:iu},Me;(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"})(Me||(Me={}));var Di;(function(e){e.ESCAPE="escape",e.DELETE="delete",e.COPY="copy",e.CUT="cut",e.PASTE="paste",e.UNDO="undo",e.REDO="redo"})(Di||(Di={})),Cc();var xi={};xi.names=Di,xi.registerCopy=yc,xi.registerCut=wc,xi.registerDefaultShortcuts=Cc,xi.registerDelete=bc,xi.registerEscape=Ec,xi.registerPaste=Sc,xi.registerRedo=Rc,xi.registerUndo=Ic;var a_={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"}},c_={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"}},h_=new Ln("zelos",a_,c_),nu={};nu.Classic=tl,nu.Zelos=h_;var su=class{constructor(e,t,i){this.id_=e.toolboxitemid||F(),this.level_=(this.parent_=i||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){}},vi=class extends su{constructor(e,t,i){super(e,t,i),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>>/handdelete.cur"), auto; } @@ -789,17 +789,17 @@ Blockly.YourGeneratorName.nameDB_.setVariableMap(workspace.getVariableMap());`), .blocklyToolboxContents:focus { outline: none; } -`),m(pe.TOOLBOX,Fi,qf);var em=class extends rl{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 fi({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===Ce.TOP?Ce.BOTTOM:Ce.TOP,this.flyout=new(c(pe.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(e)):(e.toolboxPosition=this.workspace.toolboxPosition===Ce.RIGHT?Ce.LEFT:Ce.RIGHT,this.flyout=new(c(pe.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(e)),this.workspace.addChangeListener(this.onDelete_.bind(this)))}createDom(){this.svgGroup_=ee(q.G,{class:"blocklyTrash"});let e;const t=String(Math.random()).substring(2);e=ee(q.CLIPPATH,{id:"blocklyTrashBodyClipPath"+t},this.svgGroup_),ee(q.RECT,{width:Is,height:ul,y:Rs},e);const i=ee(q.IMAGE,{width:Dt.width,x:-ru,height:Dt.height,y:-ou,"clip-path":"url(#blocklyTrashBodyClipPath"+t+")"},this.svgGroup_);return i.setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),e=ee(q.CLIPPATH,{id:"blocklyTrashLidClipPath"+t},this.svgGroup_),ee(q.RECT,{width:Is,height:Rs},e),this.svgLid_=ee(q.IMAGE,{width:Dt.width,x:-ru,height:Dt.height,y:-ou,"clip-path":"url(#blocklyTrashLidClipPath"+t+")"},this.svgGroup_),this.svgLid_.setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),kt(this.svgGroup_,"pointerdown",this,this.blockMouseDownWhenOpenable_),kt(this.svgGroup_,"pointerup",this,this.click),kt(i,"pointerover",this,this.mouseOver_),kt(i,"pointerout",this,this.mouseOut_),this.animateLid_(),this.svgGroup_}init(){0{let i;(i=this.flyout)==null||i.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 i=Oo(this.workspace,e);e=Ao(i,new Tt(Is,ul+Rs),u_,tm,e,this.workspace),t=Lo(e,tm,i.vertical===Ki.TOP?pn.DOWN:pn.UP,t),this.top_=t.top,this.left_=t.left;var n;(n=this.svgGroup_)==null||n.setAttribute("transform","translate("+this.left_+","+this.top_+")")}}getBoundingRectangle(){return new ct(this.top_,this.top_+ul+Rs,this.left_,this.left_+Is)}getClientRect(){if(!this.svgGroup_)return null;var e=this.svgGroup_.getBoundingClientRect();const t=e.top+ou-dl;return e=e.left+ru-dl,new ct(t,t+Rs+ul+2*dl,e,e+Is+2*dl)}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=g_;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_*nm),t=im+this.lidOpen_*(f_-im),this.svgGroup_&&(this.svgGroup_.style.opacity=`${t}`),this.lidOpen_>this.minOpenness_&&1>this.lidOpen_&&(this.lidTask_=setTimeout(this.animateLid_.bind(this),p_/e))}setLidAngle_(e){const t=this.workspace.toolboxPosition===Ce.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let i;(i=this.svgLid_)==null||i.setAttribute("transform","rotate("+(t?-e:e)+","+(t?4:Is-4)+","+(Rs-2)+")")}setMinOpenness_(e){this.minOpenness_=e,this.isLidOpen||this.setLidAngle_(e*nm)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents_()&&this.openFlyout()}fireUiEvent_(e){e=new(le(or))(e,this.workspace.id),O(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!==Ri||e.type!==Ri||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_(d_)}}}cleanBlockJson_(e){function t(i){if(i){if(delete i.id,delete i.x,delete i.y,delete i.enabled,i.icons&&i.icons.comment){var n=i.icons.comment;delete n.height,delete n.width,delete n.pinned}n=i.inputs;for(var u in n){var E=n[u];const G=E.block;E=E.shadow,G&&t(G),E&&t(E)}i.next&&(u=i.next,i=u.block,u=u.shadow,i&&t(i),u&&t(u))}}return e=JSON.parse(JSON.stringify(e)),t(e),Object.assign({},{kind:"BLOCK"},e)}},Is=47,ul=44,Rs=16,tm=20,u_=20,dl=10,ru=0,ou=32,d_=.1,p_=80,g_=4,im=.4,f_=.8,nm=45,Ge={};Ge.Coordinate=ge,Ge.KeyCodes=Me,Ge.Rect=ct,Ge.Size=Tt,Ge.Svg=q,Ge.aria=Tr,Ge.array=Jg,Ge.arrayRemove=zp,Ge.browserEvents=Vi,Ge.checkMessageReferences=Hp,Ge.colour=It,Ge.deprecation=_t,Ge.dom=ft,Ge.extensions=r.module$build$src$core$extensions,Ge.getBlockTypeCounts=Yp,Ge.getDocumentScroll=Xp,Ge.getInjectionDivXY_=Fp,Ge.getRelativeXY=Pp,Ge.getViewportBBox=Wp,Ge.idGenerator=No,Ge.is3dSupported=Vp,Ge.math=Ko,Ge.object=Er,Ge.parseBlockColour=jp,Ge.parsing=vr,Ge.replaceMessageReferences=Up,Ge.runAfterPageLoad=Jp,Ge.screenToWsCoordinates=Kp,Ge.string=r.module$build$src$core$utils$string,Ge.style=Ai,Ge.svgMath=ln,Ge.svgPaths=Xi,Ge.tokenizeInterpolation=Gp,Ge.toolbox=cn,Ge.userAgent=Hi,Ge.xml=r.module$build$src$core$utils$xml;var m_="9.3.3",__=r.Align$$module$build$src$core$input.LEFT,$_=r.Align$$module$build$src$core$input.CENTRE,v_=r.Align$$module$build$src$core$input.RIGHT,T_=$e.INPUT_VALUE,E_=$e.OUTPUT_VALUE,b_=$e.NEXT_STATEMENT,y_=$e.PREVIOUS_STATEMENT,w_=Ae.DUMMY,S_=Ce.TOP,I_=Ce.BOTTOM,R_=Ce.LEFT,C_=Ce.RIGHT;Pr.prototype.newBlock=function(e,t){return new $s(this,e,t)},_i.prototype.newBlock=function(e,t){return new ii(this,e,t)},_i.newTrashcan=function(e){return new em(e)},St.prototype.showContextMenu=function(e){if(!this.workspace.options.readOnly){var t=[];this.isDeletable()&&this.isMovable()&&(t.push(Pa(this)),t.push(Ba(this))),Zs(e,t,this.RTL)}},r.Mutator$$module$build$src$core$mutator.prototype.newWorkspaceSvg=function(e){return new _i(e)},Nt.prototype.populateProcedures=function(e){e=Ro(e),e=e[0].concat(e[1]);for(let t=0;t=this.workspace.options.maxTrashcanContents||(e=new fi({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===Ce.TOP?Ce.BOTTOM:Ce.TOP,this.flyout=new(c(pe.FLYOUTS_HORIZONTAL_TOOLBOX,this.workspace.options,!0))(e)):(e.toolboxPosition=this.workspace.toolboxPosition===Ce.RIGHT?Ce.LEFT:Ce.RIGHT,this.flyout=new(c(pe.FLYOUTS_VERTICAL_TOOLBOX,this.workspace.options,!0))(e)),this.workspace.addChangeListener(this.onDelete_.bind(this)))}createDom(){this.svgGroup_=ee(q.G,{class:"blocklyTrash"});let e;const t=String(Math.random()).substring(2);e=ee(q.CLIPPATH,{id:"blocklyTrashBodyClipPath"+t},this.svgGroup_),ee(q.RECT,{width:Rs,height:ul,y:Cs},e);const i=ee(q.IMAGE,{width:Dt.width,x:-ru,height:Dt.height,y:-ou,"clip-path":"url(#blocklyTrashBodyClipPath"+t+")"},this.svgGroup_);return i.setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),e=ee(q.CLIPPATH,{id:"blocklyTrashLidClipPath"+t},this.svgGroup_),ee(q.RECT,{width:Rs,height:Cs},e),this.svgLid_=ee(q.IMAGE,{width:Dt.width,x:-ru,height:Dt.height,y:-ou,"clip-path":"url(#blocklyTrashLidClipPath"+t+")"},this.svgGroup_),this.svgLid_.setAttributeNS(Ht,"xlink:href",this.workspace.options.pathToMedia+Dt.url),At(this.svgGroup_,"pointerdown",this,this.blockMouseDownWhenOpenable_),At(this.svgGroup_,"pointerup",this,this.click),At(i,"pointerover",this,this.mouseOver_),At(i,"pointerout",this,this.mouseOut_),this.animateLid_(),this.svgGroup_}init(){0{let i;(i=this.flyout)==null||i.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 i=Oo(this.workspace,e);e=ko(i,new Tt(Rs,ul+Cs),u_,em,e,this.workspace),t=Lo(e,em,i.vertical===Ki.TOP?pn.DOWN:pn.UP,t),this.top_=t.top,this.left_=t.left;var n;(n=this.svgGroup_)==null||n.setAttribute("transform","translate("+this.left_+","+this.top_+")")}}getBoundingRectangle(){return new ct(this.top_,this.top_+ul+Cs,this.left_,this.left_+Rs)}getClientRect(){if(!this.svgGroup_)return null;var e=this.svgGroup_.getBoundingClientRect();const t=e.top+ou-dl;return e=e.left+ru-dl,new ct(t,t+Cs+ul+2*dl,e,e+Rs+2*dl)}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=g_;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_*im),t=tm+this.lidOpen_*(f_-tm),this.svgGroup_&&(this.svgGroup_.style.opacity=`${t}`),this.lidOpen_>this.minOpenness_&&1>this.lidOpen_&&(this.lidTask_=setTimeout(this.animateLid_.bind(this),p_/e))}setLidAngle_(e){const t=this.workspace.toolboxPosition===Ce.RIGHT||this.workspace.horizontalLayout&&this.workspace.RTL;let i;(i=this.svgLid_)==null||i.setAttribute("transform","rotate("+(t?-e:e)+","+(t?4:Rs-4)+","+(Cs-2)+")")}setMinOpenness_(e){this.minOpenness_=e,this.isLidOpen||this.setLidAngle_(e*im)}closeLid(){this.setLidOpen(!1)}click(){this.hasContents_()&&this.openFlyout()}fireUiEvent_(e){e=new(le(or))(e,this.workspace.id),k(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!==Ri||e.type!==Ri||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_(d_)}}}cleanBlockJson_(e){function t(i){if(i){if(delete i.id,delete i.x,delete i.y,delete i.enabled,i.icons&&i.icons.comment){var n=i.icons.comment;delete n.height,delete n.width,delete n.pinned}n=i.inputs;for(var u in n){var b=n[u];const G=b.block;b=b.shadow,G&&t(G),b&&t(b)}i.next&&(u=i.next,i=u.block,u=u.shadow,i&&t(i),u&&t(u))}}return e=JSON.parse(JSON.stringify(e)),t(e),Object.assign({},{kind:"BLOCK"},e)}},Rs=47,ul=44,Cs=16,em=20,u_=20,dl=10,ru=0,ou=32,d_=.1,p_=80,g_=4,tm=.4,f_=.8,im=45,Ge={};Ge.Coordinate=ge,Ge.KeyCodes=Me,Ge.Rect=ct,Ge.Size=Tt,Ge.Svg=q,Ge.aria=Tr,Ge.array=jg,Ge.arrayRemove=Wp,Ge.browserEvents=Vi,Ge.checkMessageReferences=Up,Ge.colour=It,Ge.deprecation=_t,Ge.dom=ft,Ge.extensions=s.module$build$src$core$extensions,Ge.getBlockTypeCounts=Xp,Ge.getDocumentScroll=zp,Ge.getInjectionDivXY_=Pp,Ge.getRelativeXY=Bp,Ge.getViewportBBox=Vp,Ge.idGenerator=No,Ge.is3dSupported=Hp,Ge.math=Ko,Ge.object=Er,Ge.parseBlockColour=Kp,Ge.parsing=vr,Ge.replaceMessageReferences=Gp,Ge.runAfterPageLoad=jp,Ge.screenToWsCoordinates=Yp,Ge.string=s.module$build$src$core$utils$string,Ge.style=ki,Ge.svgMath=ln,Ge.svgPaths=Xi,Ge.tokenizeInterpolation=Fp,Ge.toolbox=cn,Ge.userAgent=Hi,Ge.xml=s.module$build$src$core$utils$xml;var m_="9.3.3",__=s.Align$$module$build$src$core$input.LEFT,$_=s.Align$$module$build$src$core$input.CENTRE,v_=s.Align$$module$build$src$core$input.RIGHT,T_=$e.INPUT_VALUE,E_=$e.OUTPUT_VALUE,b_=$e.NEXT_STATEMENT,y_=$e.PREVIOUS_STATEMENT,w_=ke.DUMMY,S_=Ce.TOP,I_=Ce.BOTTOM,R_=Ce.LEFT,C_=Ce.RIGHT;Pr.prototype.newBlock=function(e,t){return new vs(this,e,t)},_i.prototype.newBlock=function(e,t){return new ni(this,e,t)},_i.newTrashcan=function(e){return new qf(e)},St.prototype.showContextMenu=function(e){if(!this.workspace.options.readOnly){var t=[];this.isDeletable()&&this.isMovable()&&(t.push(Pa(this)),t.push(Ba(this))),Zs(e,t,this.RTL)}},s.Mutator$$module$build$src$core$mutator.prototype.newWorkspaceSvg=function(e){return new _i(e)},Nt.prototype.populateProcedures=function(e){e=Ro(e),e=e[0].concat(e[1]);for(let t=0;t","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 h={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}"};p.module$build$src$core$extensions.register("logic_op_tooltip",p.module$build$src$core$extensions.buildTooltipForDropdown("OP",h));var d={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const M=p.module$build$src$core$utils$xml.createElement("mutation");return this.elseifCount_&&M.setAttribute("elseif",this.elseifCount_),this.elseCount_&&M.setAttribute("else",1),M},domToMutation:function(M){this.elseifCount_=parseInt(M.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(M.getAttribute("else"),10)||0,this.rebuildShape_()},saveExtraState:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const M=Object.create(null);return this.elseifCount_&&(M.elseIfCount=this.elseifCount_),this.elseCount_&&(M.hasElse=!0),M},loadExtraState:function(M){this.elseifCount_=M.elseIfCount||0,this.elseCount_=M.hasElse?1:0,this.updateShape_()},decompose:function(M){const U=M.newBlock("controls_if_if");U.initSvg();let j=U.nextConnection;for(let ne=1;ne<=this.elseifCount_;ne++){const se=M.newBlock("controls_if_elseif");se.initSvg(),j.connect(se.previousConnection),j=se.nextConnection}return this.elseCount_&&(M=M.newBlock("controls_if_else"),M.initSvg(),j.connect(M.previousConnection)),U},compose:function(M){M=M.nextConnection.targetBlock(),this.elseCount_=this.elseifCount_=0;const U=[null],j=[null];let ne=null;for(;M;){if(!M.isInsertionMarker())switch(M.type){case"controls_if_elseif":this.elseifCount_++,U.push(M.valueConnection_),j.push(M.statementConnection_);break;case"controls_if_else":this.elseCount_++,ne=M.statementConnection_;break;default:throw TypeError("Unknown block type: "+M.type)}M=M.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(U,j,ne)},saveConnections:function(M){M=M.nextConnection.targetBlock();let U=1;for(;M;){if(!M.isInsertionMarker())switch(M.type){case"controls_if_elseif":var j=this.getInput("IF"+U);const ne=this.getInput("DO"+U);M.valueConnection_=j&&j.connection.targetConnection,M.statementConnection_=ne&&ne.connection.targetConnection,U++;break;case"controls_if_else":j=this.getInput("ELSE"),M.statementConnection_=j&&j.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+M.type)}M=M.getNextBlock()}},rebuildShape_:function(){const M=[null],U=[null];let j=null;this.getInput("ELSE")&&(j=this.getInput("ELSE").connection.targetConnection);for(let ne=1;this.getInput("IF"+ne);ne++){const se=this.getInput("IF"+ne),Fe=this.getInput("DO"+ne);M.push(se.connection.targetConnection),U.push(Fe.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(M,U,j)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var M=1;this.getInput("IF"+M);M++)this.removeInput("IF"+M),this.removeInput("DO"+M);for(M=1;M<=this.elseifCount_;M++)this.appendValueInput("IF"+M).setCheck("Boolean").appendField(o.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+M).appendField(o.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(o.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(M,U,j){for(let ne=1;ne<=this.elseifCount_;ne++)p.Mutator$$module$build$src$core$mutator.reconnect(M[ne],this,"IF"+ne),p.Mutator$$module$build$src$core$mutator.reconnect(U[ne],this,"DO"+ne);p.Mutator$$module$build$src$core$mutator.reconnect(j,this,"ELSE")}};p.module$build$src$core$extensions.registerMutator("controls_if_mutator",d,null,["controls_if_elseif","controls_if_else"]);var g=function(){this.setTooltip(function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return o.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return o.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return o.CONTROLS_IF_TOOLTIP_4}else return o.CONTROLS_IF_TOOLTIP_1;return""}.bind(this))};p.module$build$src$core$extensions.register("controls_if_tooltip",g);var _={onchange:function(M){this.prevBlocks_||(this.prevBlocks_=[null,null]);var U=this.getInputTargetBlock("A");const j=this.getInputTargetBlock("B");U&&j&&!this.workspace.connectionChecker.doTypeChecks(U.outputConnection,j.outputConnection)&&(p.module$build$src$core$events$events.setGroup(M.group),M=this.prevBlocks_[0],M!==U&&(U.unplug(),!M||M.isDisposed()||M.isShadow()||this.getInput("A").connection.connect(M.outputConnection)),U=this.prevBlocks_[1],U!==j&&(j.unplug(),!U||U.isDisposed()||U.isShadow()||this.getInput("B").connection.connect(U.outputConnection)),this.bumpNeighbours(),p.module$build$src$core$events$events.setGroup(!1)),this.prevBlocks_[0]=this.getInputTargetBlock("A"),this.prevBlocks_[1]=this.getInputTargetBlock("B")}},v=function(){this.mixin(_)};p.module$build$src$core$extensions.register("logic_compare",v);var k={prevParentConnection_:null,onchange:function(M){const U=this.getInputTargetBlock("THEN"),j=this.getInputTargetBlock("ELSE"),ne=this.outputConnection.targetConnection;if((U||j)&&ne)for(let se=0;2>se;se++){const Fe=se===1?U:j;Fe&&!Fe.workspace.connectionChecker.doTypeChecks(Fe.outputConnection,ne)&&(p.module$build$src$core$events$events.setGroup(M.group),ne===this.prevParentConnection_?(this.unplug(),ne.getSourceBlock().bumpNeighbours()):(Fe.unplug(),Fe.bumpNeighbours()),p.module$build$src$core$events$events.setGroup(!1))}this.prevParentConnection_=ne}};p.module$build$src$core$extensions.registerMixin("logic_ternary",k),l(s.blocks);var I={};p.module$build$src$core$contextmenu,p.module$build$src$core$events$events,p.module$build$src$core$extensions,p.module$build$src$core$variables,p.module$build$src$core$utils$xml;var S=p.module$build$src$core$msg.Msg,b=p.module$build$src$core$common.createBlockDefinitionsFromJsonArray,x=p.module$build$src$core$common.defineBlocks;I.blocks=b([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number"}],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",align:"RIGHT"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",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 N={WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"};p.module$build$src$core$extensions.register("controls_whileUntil_tooltip",p.module$build$src$core$extensions.buildTooltipForDropdown("MODE",N));var D={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"};p.module$build$src$core$extensions.register("controls_flow_tooltip",p.module$build$src$core$extensions.buildTooltipForDropdown("FLOW",D));var R={customContextMenu:function(M){if(!this.isInFlyout){var U=this.getField("VAR").getVariable(),j=U.name;if(!this.isCollapsed()&&j!==null){const ne={enabled:!0};ne.text=S.VARIABLES_SET_CREATE_GET.replace("%1",j),U=p.module$build$src$core$variables.generateVariableFieldDom(U),j=p.module$build$src$core$utils$xml.createElement("block"),j.setAttribute("type","variables_get"),j.appendChild(U),ne.callback=p.module$build$src$core$contextmenu.callbackFactory(this,j),M.push(ne)}}}};p.module$build$src$core$extensions.registerMixin("contextMenu_newGetVariableBlock",R),p.module$build$src$core$extensions.register("controls_for_tooltip",p.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR")),p.module$build$src$core$extensions.register("controls_forEach_tooltip",p.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR")),I.loopTypes=new Set(["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]);var w={getSurroundLoop:function(){let M=this;do{if(I.loopTypes.has(M.type))return M;M=M.getSurroundParent()}while(M);return null},onchange:function(M){if(this.workspace.isDragging&&!this.workspace.isDragging()&&M.type===p.module$build$src$core$events$events.BLOCK_MOVE){var U=this.getSurroundLoop(this);if(this.setWarningText(U?null:S.CONTROLS_FLOW_STATEMENTS_WARNING),!this.isInFlyout){const j=p.module$build$src$core$events$events.getGroup();p.module$build$src$core$events$events.setGroup(M.group),this.setEnabled(U),p.module$build$src$core$events$events.setGroup(j)}}}};p.module$build$src$core$extensions.registerMixin("controls_flow_in_loop_check",w),x(I.blocks);var F=p.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",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"},{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"}],inputsInline:!0,output:"Number",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}"}]),A={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}"};p.register$$module$build$src$core$extensions("math_op_tooltip",p.buildTooltipForDropdown$$module$build$src$core$extensions("OP",A));var T={mutationToDom:function(){const M=p.createElement$$module$build$src$core$utils$xml("mutation"),U=this.getFieldValue("PROPERTY")==="DIVISIBLE_BY";return M.setAttribute("divisor_input",String(U)),M},domToMutation:function(M){M=M.getAttribute("divisor_input")==="true",this.updateShape_(M)},updateShape_:function(M){const U=this.getInput("DIVISOR");M?U||this.appendValueInput("DIVISOR").setCheck("Number"):U&&this.removeInput("DIVISOR")}},L=function(){this.getField("PROPERTY").setValidator(function(M){M=M==="DIVISIBLE_BY",this.getSourceBlock().updateShape_(M)})};p.registerMutator$$module$build$src$core$extensions("math_is_divisibleby_mutator",T,L),p.register$$module$build$src$core$extensions("math_change_tooltip",p.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_MATH_CHANGE_TOOLTIP}","VAR"));var O={updateType_:function(M){M==="MODE"?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){const M=p.createElement$$module$build$src$core$utils$xml("mutation");return M.setAttribute("op",this.getFieldValue("OP")),M},domToMutation:function(M){if(M=M.getAttribute("op"),M===null)throw new TypeError("xmlElement had no op attribute");this.updateType_(M)}},H=function(){this.getField("OP").setValidator(function(M){this.updateType_(M)}.bind(this))};p.registerMutator$$module$build$src$core$extensions("math_modes_of_list_mutator",O,H),p.defineBlocks$$module$build$src$core$common(F);var V={};V.blocks=F;var W={};p.module$build$src$core$contextmenu,p.module$build$src$core$events$events,p.module$build$src$core$procedures,p.module$build$src$core$variables,p.module$build$src$core$xml,p.module$build$src$core$field_registry,p.module$build$src$core$utils$xml,p.Align$$module$build$src$core$input,p.config$$module$build$src$core$config;var K=p.module$build$src$core$msg.Msg;p.Mutator$$module$build$src$core$mutator,p.module$build$src$core$names.Names;var Q=p.module$build$src$core$common.defineBlocks;W.blocks={};var ie={setStatements_:function(M){this.hasStatements_!==M&&(M?(this.appendStatementInput("STACK").appendField(K.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=M)},updateParams_:function(){let M="";this.arguments_.length&&(M=K.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),p.module$build$src$core$events$events.disable();try{this.setFieldValue(M,"PARAMS")}finally{p.module$build$src$core$events$events.enable()}},mutationToDom:function(M){const U=p.module$build$src$core$utils$xml.createElement("mutation");M&&U.setAttribute("name",this.getFieldValue("NAME"));for(let j=0;j","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 h={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}"};p.module$build$src$core$extensions.register("logic_op_tooltip",p.module$build$src$core$extensions.buildTooltipForDropdown("OP",h));var d={elseifCount_:0,elseCount_:0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const L=p.module$build$src$core$utils$xml.createElement("mutation");return this.elseifCount_&&L.setAttribute("elseif",this.elseifCount_),this.elseCount_&&L.setAttribute("else",1),L},domToMutation:function(L){this.elseifCount_=parseInt(L.getAttribute("elseif"),10)||0,this.elseCount_=parseInt(L.getAttribute("else"),10)||0,this.rebuildShape_()},saveExtraState:function(){if(!this.elseifCount_&&!this.elseCount_)return null;const L=Object.create(null);return this.elseifCount_&&(L.elseIfCount=this.elseifCount_),this.elseCount_&&(L.hasElse=!0),L},loadExtraState:function(L){this.elseifCount_=L.elseIfCount||0,this.elseCount_=L.hasElse?1:0,this.updateShape_()},decompose:function(L){const U=L.newBlock("controls_if_if");U.initSvg();let j=U.nextConnection;for(let ne=1;ne<=this.elseifCount_;ne++){const se=L.newBlock("controls_if_elseif");se.initSvg(),j.connect(se.previousConnection),j=se.nextConnection}return this.elseCount_&&(L=L.newBlock("controls_if_else"),L.initSvg(),j.connect(L.previousConnection)),U},compose:function(L){L=L.nextConnection.targetBlock(),this.elseCount_=this.elseifCount_=0;const U=[null],j=[null];let ne=null;for(;L;){if(!L.isInsertionMarker())switch(L.type){case"controls_if_elseif":this.elseifCount_++,U.push(L.valueConnection_),j.push(L.statementConnection_);break;case"controls_if_else":this.elseCount_++,ne=L.statementConnection_;break;default:throw TypeError("Unknown block type: "+L.type)}L=L.getNextBlock()}this.updateShape_(),this.reconnectChildBlocks_(U,j,ne)},saveConnections:function(L){L=L.nextConnection.targetBlock();let U=1;for(;L;){if(!L.isInsertionMarker())switch(L.type){case"controls_if_elseif":var j=this.getInput("IF"+U);const ne=this.getInput("DO"+U);L.valueConnection_=j&&j.connection.targetConnection,L.statementConnection_=ne&&ne.connection.targetConnection,U++;break;case"controls_if_else":j=this.getInput("ELSE"),L.statementConnection_=j&&j.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+L.type)}L=L.getNextBlock()}},rebuildShape_:function(){const L=[null],U=[null];let j=null;this.getInput("ELSE")&&(j=this.getInput("ELSE").connection.targetConnection);for(let ne=1;this.getInput("IF"+ne);ne++){const se=this.getInput("IF"+ne),Fe=this.getInput("DO"+ne);L.push(se.connection.targetConnection),U.push(Fe.connection.targetConnection)}this.updateShape_(),this.reconnectChildBlocks_(L,U,j)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var L=1;this.getInput("IF"+L);L++)this.removeInput("IF"+L),this.removeInput("DO"+L);for(L=1;L<=this.elseifCount_;L++)this.appendValueInput("IF"+L).setCheck("Boolean").appendField(o.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+L).appendField(o.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(o.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(L,U,j){for(let ne=1;ne<=this.elseifCount_;ne++)p.Mutator$$module$build$src$core$mutator.reconnect(L[ne],this,"IF"+ne),p.Mutator$$module$build$src$core$mutator.reconnect(U[ne],this,"DO"+ne);p.Mutator$$module$build$src$core$mutator.reconnect(j,this,"ELSE")}};p.module$build$src$core$extensions.registerMutator("controls_if_mutator",d,null,["controls_if_elseif","controls_if_else"]);var g=function(){this.setTooltip(function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return o.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return o.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return o.CONTROLS_IF_TOOLTIP_4}else return o.CONTROLS_IF_TOOLTIP_1;return""}.bind(this))};p.module$build$src$core$extensions.register("controls_if_tooltip",g);var _={onchange:function(L){this.prevBlocks_||(this.prevBlocks_=[null,null]);var U=this.getInputTargetBlock("A");const j=this.getInputTargetBlock("B");U&&j&&!this.workspace.connectionChecker.doTypeChecks(U.outputConnection,j.outputConnection)&&(p.module$build$src$core$events$events.setGroup(L.group),L=this.prevBlocks_[0],L!==U&&(U.unplug(),!L||L.isDisposed()||L.isShadow()||this.getInput("A").connection.connect(L.outputConnection)),U=this.prevBlocks_[1],U!==j&&(j.unplug(),!U||U.isDisposed()||U.isShadow()||this.getInput("B").connection.connect(U.outputConnection)),this.bumpNeighbours(),p.module$build$src$core$events$events.setGroup(!1)),this.prevBlocks_[0]=this.getInputTargetBlock("A"),this.prevBlocks_[1]=this.getInputTargetBlock("B")}},v=function(){this.mixin(_)};p.module$build$src$core$extensions.register("logic_compare",v);var M={prevParentConnection_:null,onchange:function(L){const U=this.getInputTargetBlock("THEN"),j=this.getInputTargetBlock("ELSE"),ne=this.outputConnection.targetConnection;if((U||j)&&ne)for(let se=0;2>se;se++){const Fe=se===1?U:j;Fe&&!Fe.workspace.connectionChecker.doTypeChecks(Fe.outputConnection,ne)&&(p.module$build$src$core$events$events.setGroup(L.group),ne===this.prevParentConnection_?(this.unplug(),ne.getSourceBlock().bumpNeighbours()):(Fe.unplug(),Fe.bumpNeighbours()),p.module$build$src$core$events$events.setGroup(!1))}this.prevParentConnection_=ne}};p.module$build$src$core$extensions.registerMixin("logic_ternary",M),l(r.blocks);var y={};p.module$build$src$core$contextmenu,p.module$build$src$core$events$events,p.module$build$src$core$extensions,p.module$build$src$core$variables,p.module$build$src$core$utils$xml;var I=p.module$build$src$core$msg.Msg,w=p.module$build$src$core$common.createBlockDefinitionsFromJsonArray,x=p.module$build$src$core$common.defineBlocks;y.blocks=w([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number"}],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",align:"RIGHT"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",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 N={WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"};p.module$build$src$core$extensions.register("controls_whileUntil_tooltip",p.module$build$src$core$extensions.buildTooltipForDropdown("MODE",N));var D={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"};p.module$build$src$core$extensions.register("controls_flow_tooltip",p.module$build$src$core$extensions.buildTooltipForDropdown("FLOW",D));var R={customContextMenu:function(L){if(!this.isInFlyout){var U=this.getField("VAR").getVariable(),j=U.name;if(!this.isCollapsed()&&j!==null){const ne={enabled:!0};ne.text=I.VARIABLES_SET_CREATE_GET.replace("%1",j),U=p.module$build$src$core$variables.generateVariableFieldDom(U),j=p.module$build$src$core$utils$xml.createElement("block"),j.setAttribute("type","variables_get"),j.appendChild(U),ne.callback=p.module$build$src$core$contextmenu.callbackFactory(this,j),L.push(ne)}}}};p.module$build$src$core$extensions.registerMixin("contextMenu_newGetVariableBlock",R),p.module$build$src$core$extensions.register("controls_for_tooltip",p.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR")),p.module$build$src$core$extensions.register("controls_forEach_tooltip",p.module$build$src$core$extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR")),y.loopTypes=new Set(["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]);var S={getSurroundLoop:function(){let L=this;do{if(y.loopTypes.has(L.type))return L;L=L.getSurroundParent()}while(L);return null},onchange:function(L){if(this.workspace.isDragging&&!this.workspace.isDragging()&&L.type===p.module$build$src$core$events$events.BLOCK_MOVE){var U=this.getSurroundLoop(this);if(this.setWarningText(U?null:I.CONTROLS_FLOW_STATEMENTS_WARNING),!this.isInFlyout){const j=p.module$build$src$core$events$events.getGroup();p.module$build$src$core$events$events.setGroup(L.group),this.setEnabled(U),p.module$build$src$core$events$events.setGroup(j)}}}};p.module$build$src$core$extensions.registerMixin("controls_flow_in_loop_check",S),x(y.blocks);var F=p.createBlockDefinitionsFromJsonArray$$module$build$src$core$common([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",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"},{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"}],inputsInline:!0,output:"Number",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}"}]),A={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}"};p.register$$module$build$src$core$extensions("math_op_tooltip",p.buildTooltipForDropdown$$module$build$src$core$extensions("OP",A));var E={mutationToDom:function(){const L=p.createElement$$module$build$src$core$utils$xml("mutation"),U=this.getFieldValue("PROPERTY")==="DIVISIBLE_BY";return L.setAttribute("divisor_input",String(U)),L},domToMutation:function(L){L=L.getAttribute("divisor_input")==="true",this.updateShape_(L)},updateShape_:function(L){const U=this.getInput("DIVISOR");L?U||this.appendValueInput("DIVISOR").setCheck("Number"):U&&this.removeInput("DIVISOR")}},O=function(){this.getField("PROPERTY").setValidator(function(L){L=L==="DIVISIBLE_BY",this.getSourceBlock().updateShape_(L)})};p.registerMutator$$module$build$src$core$extensions("math_is_divisibleby_mutator",E,O),p.register$$module$build$src$core$extensions("math_change_tooltip",p.buildTooltipWithFieldText$$module$build$src$core$extensions("%{BKY_MATH_CHANGE_TOOLTIP}","VAR"));var k={updateType_:function(L){L==="MODE"?this.outputConnection.setCheck("Array"):this.outputConnection.setCheck("Number")},mutationToDom:function(){const L=p.createElement$$module$build$src$core$utils$xml("mutation");return L.setAttribute("op",this.getFieldValue("OP")),L},domToMutation:function(L){if(L=L.getAttribute("op"),L===null)throw new TypeError("xmlElement had no op attribute");this.updateType_(L)}},H=function(){this.getField("OP").setValidator(function(L){this.updateType_(L)}.bind(this))};p.registerMutator$$module$build$src$core$extensions("math_modes_of_list_mutator",k,H),p.defineBlocks$$module$build$src$core$common(F);var V={};V.blocks=F;var W={};p.module$build$src$core$contextmenu,p.module$build$src$core$events$events,p.module$build$src$core$procedures,p.module$build$src$core$variables,p.module$build$src$core$xml,p.module$build$src$core$field_registry,p.module$build$src$core$utils$xml,p.Align$$module$build$src$core$input,p.config$$module$build$src$core$config;var K=p.module$build$src$core$msg.Msg;p.Mutator$$module$build$src$core$mutator,p.module$build$src$core$names.Names;var Q=p.module$build$src$core$common.defineBlocks;W.blocks={};var ie={setStatements_:function(L){this.hasStatements_!==L&&(L?(this.appendStatementInput("STACK").appendField(K.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=L)},updateParams_:function(){let L="";this.arguments_.length&&(L=K.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),p.module$build$src$core$events$events.disable();try{this.setFieldValue(L,"PARAMS")}finally{p.module$build$src$core$events$events.enable()}},mutationToDom:function(L){const U=p.module$build$src$core$utils$xml.createElement("mutation");L&&U.setAttribute("name",this.getFieldValue("NAME"));for(let j=0;jo?d=g=this.ORDER_SUBTRACTION:c&&(d=g=this.ORDER_UNARY_NEGATION),a=this.valueToCode(a,s,g)||h,p.module$build$src$core$utils$string.isNumber(a)?(a=Number(a)+o,c&&(a=-a)):(0o&&(a=a+" - "+-o),c&&(a=o?"-("+a+")":"-"+a),d=Math.floor(d),l=Math.floor(l),d&&l>=d&&(a="("+a+")")),a},m.javascriptGenerator.colour_picker=function(a){return[m.javascriptGenerator.quote_(a.getFieldValue("COLOUR")),m.javascriptGenerator.ORDER_ATOMIC]},m.javascriptGenerator.colour_random=function(a){return[m.javascriptGenerator.provideFunction_("colourRandom",` +`)},m.javascriptGenerator.scrub_=function(a,r,o){let c="";if(!a.outputConnection||!a.outputConnection.targetConnection){var l=a.getCommentText();l&&(l=p.module$build$src$core$utils$string.wrap(l,this.COMMENT_WRAP-3),c+=this.prefixLines(l+` +`,"// "));for(let h=0;ho?d=g=this.ORDER_SUBTRACTION:c&&(d=g=this.ORDER_UNARY_NEGATION),a=this.valueToCode(a,r,g)||h,p.module$build$src$core$utils$string.isNumber(a)?(a=Number(a)+o,c&&(a=-a)):(0o&&(a=a+" - "+-o),c&&(a=o?"-("+a+")":"-"+a),d=Math.floor(d),l=Math.floor(l),d&&l>=d&&(a="("+a+")")),a},m.javascriptGenerator.colour_picker=function(a){return[m.javascriptGenerator.quote_(a.getFieldValue("COLOUR")),m.javascriptGenerator.ORDER_ATOMIC]},m.javascriptGenerator.colour_random=function(a){return[m.javascriptGenerator.provideFunction_("colourRandom",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}() { var num = Math.floor(Math.random() * Math.pow(2, 24)); return '#' + ('00000' + num.toString(16)).substr(-6); } -`)+"()",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.colour_rgb=function(a){const s=m.javascriptGenerator.valueToCode(a,"RED",m.javascriptGenerator.ORDER_NONE)||0,o=m.javascriptGenerator.valueToCode(a,"GREEN",m.javascriptGenerator.ORDER_NONE)||0;return a=m.javascriptGenerator.valueToCode(a,"BLUE",m.javascriptGenerator.ORDER_NONE)||0,[m.javascriptGenerator.provideFunction_("colourRgb",` +`)+"()",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.colour_rgb=function(a){const r=m.javascriptGenerator.valueToCode(a,"RED",m.javascriptGenerator.ORDER_NONE)||0,o=m.javascriptGenerator.valueToCode(a,"GREEN",m.javascriptGenerator.ORDER_NONE)||0;return a=m.javascriptGenerator.valueToCode(a,"BLUE",m.javascriptGenerator.ORDER_NONE)||0,[m.javascriptGenerator.provideFunction_("colourRgb",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) { r = Math.max(Math.min(Number(r), 100), 0) * 2.55; g = Math.max(Math.min(Number(g), 100), 0) * 2.55; @@ -823,7 +823,7 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(r, g, b) { b = ('0' + (Math.round(b) || 0).toString(16)).slice(-2); return '#' + r + g + b; } -`)+"("+s+", "+o+", "+a+")",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.colour_blend=function(a){const s=m.javascriptGenerator.valueToCode(a,"COLOUR1",m.javascriptGenerator.ORDER_NONE)||"'#000000'",o=m.javascriptGenerator.valueToCode(a,"COLOUR2",m.javascriptGenerator.ORDER_NONE)||"'#000000'";return a=m.javascriptGenerator.valueToCode(a,"RATIO",m.javascriptGenerator.ORDER_NONE)||.5,[m.javascriptGenerator.provideFunction_("colourBlend",` +`)+"("+r+", "+o+", "+a+")",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.colour_blend=function(a){const r=m.javascriptGenerator.valueToCode(a,"COLOUR1",m.javascriptGenerator.ORDER_NONE)||"'#000000'",o=m.javascriptGenerator.valueToCode(a,"COLOUR2",m.javascriptGenerator.ORDER_NONE)||"'#000000'";return a=m.javascriptGenerator.valueToCode(a,"RATIO",m.javascriptGenerator.ORDER_NONE)||.5,[m.javascriptGenerator.provideFunction_("colourBlend",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) { ratio = Math.max(Math.min(Number(ratio), 1), 0); var r1 = parseInt(c1.substring(1, 3), 16); @@ -840,7 +840,7 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(c1, c2, ratio) { b = ('0' + (b || 0).toString(16)).slice(-2); return '#' + r + g + b; } -`)+"("+s+", "+o+", "+a+")",m.javascriptGenerator.ORDER_FUNCTION_CALL]},p.NameType$$module$build$src$core$names,m.javascriptGenerator.lists_create_empty=function(a){return["[]",m.javascriptGenerator.ORDER_ATOMIC]},m.javascriptGenerator.lists_create_with=function(a){const s=Array(a.itemCount_);for(let o=0;o",GTE:">="}[a.getFieldValue("OP")],o=s==="=="||s==="!="?m.javascriptGenerator.ORDER_EQUALITY:m.javascriptGenerator.ORDER_RELATIONAL,c=m.javascriptGenerator.valueToCode(a,"A",o)||"0";return a=m.javascriptGenerator.valueToCode(a,"B",o)||"0",[c+" "+s+" "+a,o]},m.javascriptGenerator.logic_operation=function(a){const s=a.getFieldValue("OP")==="AND"?"&&":"||",o=s==="&&"?m.javascriptGenerator.ORDER_LOGICAL_AND:m.javascriptGenerator.ORDER_LOGICAL_OR;let c=m.javascriptGenerator.valueToCode(a,"A",o);if(a=m.javascriptGenerator.valueToCode(a,"B",o),c||a){const l=s==="&&"?"true":"false";c||(c=l),a||(a=l)}else a=c="false";return[c+" "+s+" "+a,o]},m.javascriptGenerator.logic_negate=function(a){const s=m.javascriptGenerator.ORDER_LOGICAL_NOT;return["!"+(m.javascriptGenerator.valueToCode(a,"BOOL",s)||"true"),s]},m.javascriptGenerator.logic_boolean=function(a){return[a.getFieldValue("BOOL")==="TRUE"?"true":"false",m.javascriptGenerator.ORDER_ATOMIC]},m.javascriptGenerator.logic_null=function(a){return["null",m.javascriptGenerator.ORDER_ATOMIC]},m.javascriptGenerator.logic_ternary=function(a){const s=m.javascriptGenerator.valueToCode(a,"IF",m.javascriptGenerator.ORDER_CONDITIONAL)||"false",o=m.javascriptGenerator.valueToCode(a,"THEN",m.javascriptGenerator.ORDER_CONDITIONAL)||"null";return a=m.javascriptGenerator.valueToCode(a,"ELSE",m.javascriptGenerator.ORDER_CONDITIONAL)||"null",[s+" ? "+o+" : "+a,m.javascriptGenerator.ORDER_CONDITIONAL]},p.module$build$src$core$utils$string,p.NameType$$module$build$src$core$names,m.javascriptGenerator.controls_repeat_ext=function(a){let s;s=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):m.javascriptGenerator.valueToCode(a,"TIMES",m.javascriptGenerator.ORDER_ASSIGNMENT)||"0";let o=m.javascriptGenerator.statementToCode(a,"DO");o=m.javascriptGenerator.addLoopTrap(o,a),a="";const c=m.javascriptGenerator.nameDB_.getDistinctName("count",p.NameType$$module$build$src$core$names.VARIABLE);let l=s;return s.match(/^\w+$/)||p.module$build$src$core$utils$string.isNumber(s)||(l=m.javascriptGenerator.nameDB_.getDistinctName("repeat_end",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+l+" = "+s+`; + `);return[r+".slice().sort("+c+'("'+a+'", '+o+"))",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.lists_split=function(a){let r=m.javascriptGenerator.valueToCode(a,"INPUT",m.javascriptGenerator.ORDER_MEMBER);const o=m.javascriptGenerator.valueToCode(a,"DELIM",m.javascriptGenerator.ORDER_NONE)||"''";if(a=a.getFieldValue("MODE"),a==="SPLIT")r||(r="''"),a="split";else if(a==="JOIN")r||(r="[]"),a="join";else throw Error("Unknown mode: "+a);return[r+"."+a+"("+o+")",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.lists_reverse=function(a){return[(m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_FUNCTION_CALL)||"[]")+".slice().reverse()",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.controls_if=function(a){var r=0;let o="";m.javascriptGenerator.STATEMENT_PREFIX&&(o+=m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_PREFIX,a));do{const c=m.javascriptGenerator.valueToCode(a,"IF"+r,m.javascriptGenerator.ORDER_NONE)||"false";let l=m.javascriptGenerator.statementToCode(a,"DO"+r);m.javascriptGenerator.STATEMENT_SUFFIX&&(l=m.javascriptGenerator.prefixLines(m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_SUFFIX,a),m.javascriptGenerator.INDENT)+l),o+=(0",GTE:">="}[a.getFieldValue("OP")],o=r==="=="||r==="!="?m.javascriptGenerator.ORDER_EQUALITY:m.javascriptGenerator.ORDER_RELATIONAL,c=m.javascriptGenerator.valueToCode(a,"A",o)||"0";return a=m.javascriptGenerator.valueToCode(a,"B",o)||"0",[c+" "+r+" "+a,o]},m.javascriptGenerator.logic_operation=function(a){const r=a.getFieldValue("OP")==="AND"?"&&":"||",o=r==="&&"?m.javascriptGenerator.ORDER_LOGICAL_AND:m.javascriptGenerator.ORDER_LOGICAL_OR;let c=m.javascriptGenerator.valueToCode(a,"A",o);if(a=m.javascriptGenerator.valueToCode(a,"B",o),c||a){const l=r==="&&"?"true":"false";c||(c=l),a||(a=l)}else a=c="false";return[c+" "+r+" "+a,o]},m.javascriptGenerator.logic_negate=function(a){const r=m.javascriptGenerator.ORDER_LOGICAL_NOT;return["!"+(m.javascriptGenerator.valueToCode(a,"BOOL",r)||"true"),r]},m.javascriptGenerator.logic_boolean=function(a){return[a.getFieldValue("BOOL")==="TRUE"?"true":"false",m.javascriptGenerator.ORDER_ATOMIC]},m.javascriptGenerator.logic_null=function(a){return["null",m.javascriptGenerator.ORDER_ATOMIC]},m.javascriptGenerator.logic_ternary=function(a){const r=m.javascriptGenerator.valueToCode(a,"IF",m.javascriptGenerator.ORDER_CONDITIONAL)||"false",o=m.javascriptGenerator.valueToCode(a,"THEN",m.javascriptGenerator.ORDER_CONDITIONAL)||"null";return a=m.javascriptGenerator.valueToCode(a,"ELSE",m.javascriptGenerator.ORDER_CONDITIONAL)||"null",[r+" ? "+o+" : "+a,m.javascriptGenerator.ORDER_CONDITIONAL]},p.module$build$src$core$utils$string,p.NameType$$module$build$src$core$names,m.javascriptGenerator.controls_repeat_ext=function(a){let r;r=a.getField("TIMES")?String(Number(a.getFieldValue("TIMES"))):m.javascriptGenerator.valueToCode(a,"TIMES",m.javascriptGenerator.ORDER_ASSIGNMENT)||"0";let o=m.javascriptGenerator.statementToCode(a,"DO");o=m.javascriptGenerator.addLoopTrap(o,a),a="";const c=m.javascriptGenerator.nameDB_.getDistinctName("count",p.NameType$$module$build$src$core$names.VARIABLE);let l=r;return r.match(/^\w+$/)||p.module$build$src$core$utils$string.isNumber(r)||(l=m.javascriptGenerator.nameDB_.getDistinctName("repeat_end",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+l+" = "+r+`; `),a+("for (var "+c+" = 0; "+c+" < "+l+"; "+c+`++) { `+o+`} -`)},m.javascriptGenerator.controls_repeat=m.javascriptGenerator.controls_repeat_ext,m.javascriptGenerator.controls_whileUntil=function(a){const s=a.getFieldValue("MODE")==="UNTIL";let o=m.javascriptGenerator.valueToCode(a,"BOOL",s?m.javascriptGenerator.ORDER_LOGICAL_NOT:m.javascriptGenerator.ORDER_NONE)||"false",c=m.javascriptGenerator.statementToCode(a,"DO");return c=m.javascriptGenerator.addLoopTrap(c,a),s&&(o="!"+o),"while ("+o+`) { +`)},m.javascriptGenerator.controls_repeat=m.javascriptGenerator.controls_repeat_ext,m.javascriptGenerator.controls_whileUntil=function(a){const r=a.getFieldValue("MODE")==="UNTIL";let o=m.javascriptGenerator.valueToCode(a,"BOOL",r?m.javascriptGenerator.ORDER_LOGICAL_NOT:m.javascriptGenerator.ORDER_NONE)||"false",c=m.javascriptGenerator.statementToCode(a,"DO");return c=m.javascriptGenerator.addLoopTrap(c,a),r&&(o="!"+o),"while ("+o+`) { `+c+`} -`},m.javascriptGenerator.controls_for=function(a){var s=m.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),p.NameType$$module$build$src$core$names.VARIABLE),o=m.javascriptGenerator.valueToCode(a,"FROM",m.javascriptGenerator.ORDER_ASSIGNMENT)||"0",c=m.javascriptGenerator.valueToCode(a,"TO",m.javascriptGenerator.ORDER_ASSIGNMENT)||"0";const l=m.javascriptGenerator.valueToCode(a,"BY",m.javascriptGenerator.ORDER_ASSIGNMENT)||"1";let h=m.javascriptGenerator.statementToCode(a,"DO");if(h=m.javascriptGenerator.addLoopTrap(h,a),p.module$build$src$core$utils$string.isNumber(o)&&p.module$build$src$core$utils$string.isNumber(c)&&p.module$build$src$core$utils$string.isNumber(l)){var d=Number(o)<=Number(c);a="for ("+s+" = "+o+"; "+s+(d?" <= ":" >= ")+c+"; "+s,s=Math.abs(Number(l)),a=s===1?a+(d?"++":"--"):a+((d?" += ":" -= ")+s),a+=`) { +`},m.javascriptGenerator.controls_for=function(a){var r=m.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),p.NameType$$module$build$src$core$names.VARIABLE),o=m.javascriptGenerator.valueToCode(a,"FROM",m.javascriptGenerator.ORDER_ASSIGNMENT)||"0",c=m.javascriptGenerator.valueToCode(a,"TO",m.javascriptGenerator.ORDER_ASSIGNMENT)||"0";const l=m.javascriptGenerator.valueToCode(a,"BY",m.javascriptGenerator.ORDER_ASSIGNMENT)||"1";let h=m.javascriptGenerator.statementToCode(a,"DO");if(h=m.javascriptGenerator.addLoopTrap(h,a),p.module$build$src$core$utils$string.isNumber(o)&&p.module$build$src$core$utils$string.isNumber(c)&&p.module$build$src$core$utils$string.isNumber(l)){var d=Number(o)<=Number(c);a="for ("+r+" = "+o+"; "+r+(d?" <= ":" >= ")+c+"; "+r,r=Math.abs(Number(l)),a=r===1?a+(d?"++":"--"):a+((d?" += ":" -= ")+r),a+=`) { `+h+`} -`}else a="",d=o,o.match(/^\w+$/)||p.module$build$src$core$utils$string.isNumber(o)||(d=m.javascriptGenerator.nameDB_.getDistinctName(s+"_start",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+d+" = "+o+`; -`),o=c,c.match(/^\w+$/)||p.module$build$src$core$utils$string.isNumber(c)||(o=m.javascriptGenerator.nameDB_.getDistinctName(s+"_end",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+o+" = "+c+`; -`),c=m.javascriptGenerator.nameDB_.getDistinctName(s+"_inc",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+c+" = ",a=p.module$build$src$core$utils$string.isNumber(l)?a+(Math.abs(l)+`; +`}else a="",d=o,o.match(/^\w+$/)||p.module$build$src$core$utils$string.isNumber(o)||(d=m.javascriptGenerator.nameDB_.getDistinctName(r+"_start",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+d+" = "+o+`; +`),o=c,c.match(/^\w+$/)||p.module$build$src$core$utils$string.isNumber(c)||(o=m.javascriptGenerator.nameDB_.getDistinctName(r+"_end",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+o+" = "+c+`; +`),c=m.javascriptGenerator.nameDB_.getDistinctName(r+"_inc",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+c+" = ",a=p.module$build$src$core$utils$string.isNumber(l)?a+(Math.abs(l)+`; `):a+("Math.abs("+l+`); `),a+="if ("+d+" > "+o+`) { `,a+=m.javascriptGenerator.INDENT+c+" = -"+c+`; `,a=a+`} -for (`+(s+" = "+d+"; "+c+" >= 0 ? "+s+" <= "+o+" : "+s+" >= "+o+"; "+s+" += "+c+`) { +for (`+(r+" = "+d+"; "+c+" >= 0 ? "+r+" <= "+o+" : "+r+" >= "+o+"; "+r+" += "+c+`) { `+h+`} -`);return a},m.javascriptGenerator.controls_forEach=function(a){const s=m.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),p.NameType$$module$build$src$core$names.VARIABLE);var o=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_ASSIGNMENT)||"[]";let c=m.javascriptGenerator.statementToCode(a,"DO");c=m.javascriptGenerator.addLoopTrap(c,a),a="";let l=o;return o.match(/^\w+$/)||(l=m.javascriptGenerator.nameDB_.getDistinctName(s+"_list",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+l+" = "+o+`; -`),o=m.javascriptGenerator.nameDB_.getDistinctName(s+"_index",p.NameType$$module$build$src$core$names.VARIABLE),c=m.javascriptGenerator.INDENT+s+" = "+l+"["+o+`]; +`);return a},m.javascriptGenerator.controls_forEach=function(a){const r=m.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),p.NameType$$module$build$src$core$names.VARIABLE);var o=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_ASSIGNMENT)||"[]";let c=m.javascriptGenerator.statementToCode(a,"DO");c=m.javascriptGenerator.addLoopTrap(c,a),a="";let l=o;return o.match(/^\w+$/)||(l=m.javascriptGenerator.nameDB_.getDistinctName(r+"_list",p.NameType$$module$build$src$core$names.VARIABLE),a+="var "+l+" = "+o+`; +`),o=m.javascriptGenerator.nameDB_.getDistinctName(r+"_index",p.NameType$$module$build$src$core$names.VARIABLE),c=m.javascriptGenerator.INDENT+r+" = "+l+"["+o+`]; `+c,a+("for (var "+o+" in "+l+`) { `+c+`} -`)},m.javascriptGenerator.controls_flow_statements=function(a){let s="";if(m.javascriptGenerator.STATEMENT_PREFIX&&(s+=m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_PREFIX,a)),m.javascriptGenerator.STATEMENT_SUFFIX&&(s+=m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_SUFFIX,a)),m.javascriptGenerator.STATEMENT_PREFIX){const o=a.getSurroundLoop();o&&!o.suppressPrefixSuffix&&(s+=m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_PREFIX,o))}switch(a.getFieldValue("FLOW")){case"BREAK":return s+`break; -`;case"CONTINUE":return s+`continue; -`}throw Error("Unknown flow statement.")},p.NameType$$module$build$src$core$names,m.javascriptGenerator.math_number=function(a){return a=Number(a.getFieldValue("NUM")),[a,0<=a?m.javascriptGenerator.ORDER_ATOMIC:m.javascriptGenerator.ORDER_UNARY_NEGATION]},m.javascriptGenerator.math_arithmetic=function(a){var s={ADD:[" + ",m.javascriptGenerator.ORDER_ADDITION],MINUS:[" - ",m.javascriptGenerator.ORDER_SUBTRACTION],MULTIPLY:[" * ",m.javascriptGenerator.ORDER_MULTIPLICATION],DIVIDE:[" / ",m.javascriptGenerator.ORDER_DIVISION],POWER:[null,m.javascriptGenerator.ORDER_NONE]}[a.getFieldValue("OP")];const o=s[0];s=s[1];const c=m.javascriptGenerator.valueToCode(a,"A",s)||"0";return a=m.javascriptGenerator.valueToCode(a,"B",s)||"0",o?[c+o+a,s]:["Math.pow("+c+", "+a+")",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.math_single=function(a){const s=a.getFieldValue("OP");let o;if(s==="NEG")return a=m.javascriptGenerator.valueToCode(a,"NUM",m.javascriptGenerator.ORDER_UNARY_NEGATION)||"0",a[0]==="-"&&(a=" "+a),["-"+a,m.javascriptGenerator.ORDER_UNARY_NEGATION];switch(a=s==="SIN"||s==="COS"||s==="TAN"?m.javascriptGenerator.valueToCode(a,"NUM",m.javascriptGenerator.ORDER_DIVISION)||"0":m.javascriptGenerator.valueToCode(a,"NUM",m.javascriptGenerator.ORDER_NONE)||"0",s){case"ABS":o="Math.abs("+a+")";break;case"ROOT":o="Math.sqrt("+a+")";break;case"LN":o="Math.log("+a+")";break;case"EXP":o="Math.exp("+a+")";break;case"POW10":o="Math.pow(10,"+a+")";break;case"ROUND":o="Math.round("+a+")";break;case"ROUNDUP":o="Math.ceil("+a+")";break;case"ROUNDDOWN":o="Math.floor("+a+")";break;case"SIN":o="Math.sin("+a+" / 180 * Math.PI)";break;case"COS":o="Math.cos("+a+" / 180 * Math.PI)";break;case"TAN":o="Math.tan("+a+" / 180 * Math.PI)"}if(o)return[o,m.javascriptGenerator.ORDER_FUNCTION_CALL];switch(s){case"LOG10":o="Math.log("+a+") / Math.log(10)";break;case"ASIN":o="Math.asin("+a+") / Math.PI * 180";break;case"ACOS":o="Math.acos("+a+") / Math.PI * 180";break;case"ATAN":o="Math.atan("+a+") / Math.PI * 180";break;default:throw Error("Unknown math operator: "+s)}return[o,m.javascriptGenerator.ORDER_DIVISION]},m.javascriptGenerator.math_constant=function(a){return{PI:["Math.PI",m.javascriptGenerator.ORDER_MEMBER],E:["Math.E",m.javascriptGenerator.ORDER_MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",m.javascriptGenerator.ORDER_DIVISION],SQRT2:["Math.SQRT2",m.javascriptGenerator.ORDER_MEMBER],SQRT1_2:["Math.SQRT1_2",m.javascriptGenerator.ORDER_MEMBER],INFINITY:["Infinity",m.javascriptGenerator.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]},m.javascriptGenerator.math_number_property=function(a){var s={EVEN:[" % 2 === 0",m.javascriptGenerator.ORDER_MODULUS,m.javascriptGenerator.ORDER_EQUALITY],ODD:[" % 2 === 1",m.javascriptGenerator.ORDER_MODULUS,m.javascriptGenerator.ORDER_EQUALITY],WHOLE:[" % 1 === 0",m.javascriptGenerator.ORDER_MODULUS,m.javascriptGenerator.ORDER_EQUALITY],POSITIVE:[" > 0",m.javascriptGenerator.ORDER_RELATIONAL,m.javascriptGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",m.javascriptGenerator.ORDER_RELATIONAL,m.javascriptGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,m.javascriptGenerator.ORDER_MODULUS,m.javascriptGenerator.ORDER_EQUALITY],PRIME:[null,m.javascriptGenerator.ORDER_NONE,m.javascriptGenerator.ORDER_FUNCTION_CALL]};const o=a.getFieldValue("PROPERTY"),[c,l,h]=s[o];return s=m.javascriptGenerator.valueToCode(a,"NUMBER_TO_CHECK",l)||"0",o==="PRIME"?a=m.javascriptGenerator.provideFunction_("mathIsPrime",` +`)},m.javascriptGenerator.controls_flow_statements=function(a){let r="";if(m.javascriptGenerator.STATEMENT_PREFIX&&(r+=m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_PREFIX,a)),m.javascriptGenerator.STATEMENT_SUFFIX&&(r+=m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_SUFFIX,a)),m.javascriptGenerator.STATEMENT_PREFIX){const o=a.getSurroundLoop();o&&!o.suppressPrefixSuffix&&(r+=m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_PREFIX,o))}switch(a.getFieldValue("FLOW")){case"BREAK":return r+`break; +`;case"CONTINUE":return r+`continue; +`}throw Error("Unknown flow statement.")},p.NameType$$module$build$src$core$names,m.javascriptGenerator.math_number=function(a){return a=Number(a.getFieldValue("NUM")),[a,0<=a?m.javascriptGenerator.ORDER_ATOMIC:m.javascriptGenerator.ORDER_UNARY_NEGATION]},m.javascriptGenerator.math_arithmetic=function(a){var r={ADD:[" + ",m.javascriptGenerator.ORDER_ADDITION],MINUS:[" - ",m.javascriptGenerator.ORDER_SUBTRACTION],MULTIPLY:[" * ",m.javascriptGenerator.ORDER_MULTIPLICATION],DIVIDE:[" / ",m.javascriptGenerator.ORDER_DIVISION],POWER:[null,m.javascriptGenerator.ORDER_NONE]}[a.getFieldValue("OP")];const o=r[0];r=r[1];const c=m.javascriptGenerator.valueToCode(a,"A",r)||"0";return a=m.javascriptGenerator.valueToCode(a,"B",r)||"0",o?[c+o+a,r]:["Math.pow("+c+", "+a+")",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.math_single=function(a){const r=a.getFieldValue("OP");let o;if(r==="NEG")return a=m.javascriptGenerator.valueToCode(a,"NUM",m.javascriptGenerator.ORDER_UNARY_NEGATION)||"0",a[0]==="-"&&(a=" "+a),["-"+a,m.javascriptGenerator.ORDER_UNARY_NEGATION];switch(a=r==="SIN"||r==="COS"||r==="TAN"?m.javascriptGenerator.valueToCode(a,"NUM",m.javascriptGenerator.ORDER_DIVISION)||"0":m.javascriptGenerator.valueToCode(a,"NUM",m.javascriptGenerator.ORDER_NONE)||"0",r){case"ABS":o="Math.abs("+a+")";break;case"ROOT":o="Math.sqrt("+a+")";break;case"LN":o="Math.log("+a+")";break;case"EXP":o="Math.exp("+a+")";break;case"POW10":o="Math.pow(10,"+a+")";break;case"ROUND":o="Math.round("+a+")";break;case"ROUNDUP":o="Math.ceil("+a+")";break;case"ROUNDDOWN":o="Math.floor("+a+")";break;case"SIN":o="Math.sin("+a+" / 180 * Math.PI)";break;case"COS":o="Math.cos("+a+" / 180 * Math.PI)";break;case"TAN":o="Math.tan("+a+" / 180 * Math.PI)"}if(o)return[o,m.javascriptGenerator.ORDER_FUNCTION_CALL];switch(r){case"LOG10":o="Math.log("+a+") / Math.log(10)";break;case"ASIN":o="Math.asin("+a+") / Math.PI * 180";break;case"ACOS":o="Math.acos("+a+") / Math.PI * 180";break;case"ATAN":o="Math.atan("+a+") / Math.PI * 180";break;default:throw Error("Unknown math operator: "+r)}return[o,m.javascriptGenerator.ORDER_DIVISION]},m.javascriptGenerator.math_constant=function(a){return{PI:["Math.PI",m.javascriptGenerator.ORDER_MEMBER],E:["Math.E",m.javascriptGenerator.ORDER_MEMBER],GOLDEN_RATIO:["(1 + Math.sqrt(5)) / 2",m.javascriptGenerator.ORDER_DIVISION],SQRT2:["Math.SQRT2",m.javascriptGenerator.ORDER_MEMBER],SQRT1_2:["Math.SQRT1_2",m.javascriptGenerator.ORDER_MEMBER],INFINITY:["Infinity",m.javascriptGenerator.ORDER_ATOMIC]}[a.getFieldValue("CONSTANT")]},m.javascriptGenerator.math_number_property=function(a){var r={EVEN:[" % 2 === 0",m.javascriptGenerator.ORDER_MODULUS,m.javascriptGenerator.ORDER_EQUALITY],ODD:[" % 2 === 1",m.javascriptGenerator.ORDER_MODULUS,m.javascriptGenerator.ORDER_EQUALITY],WHOLE:[" % 1 === 0",m.javascriptGenerator.ORDER_MODULUS,m.javascriptGenerator.ORDER_EQUALITY],POSITIVE:[" > 0",m.javascriptGenerator.ORDER_RELATIONAL,m.javascriptGenerator.ORDER_RELATIONAL],NEGATIVE:[" < 0",m.javascriptGenerator.ORDER_RELATIONAL,m.javascriptGenerator.ORDER_RELATIONAL],DIVISIBLE_BY:[null,m.javascriptGenerator.ORDER_MODULUS,m.javascriptGenerator.ORDER_EQUALITY],PRIME:[null,m.javascriptGenerator.ORDER_NONE,m.javascriptGenerator.ORDER_FUNCTION_CALL]};const o=a.getFieldValue("PROPERTY"),[c,l,h]=r[o];return r=m.javascriptGenerator.valueToCode(a,"NUMBER_TO_CHECK",l)||"0",o==="PRIME"?a=m.javascriptGenerator.provideFunction_("mathIsPrime",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(n) { // https://en.wikipedia.org/wiki/Primality_test#Naive_methods if (n == 2 || n == 3) { @@ -936,12 +936,12 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(n) { } return true; } -`)+"("+s+")":o==="DIVISIBLE_BY"?(a=m.javascriptGenerator.valueToCode(a,"DIVISOR",m.javascriptGenerator.ORDER_MODULUS)||"0",a=s+" % "+a+" === 0"):a=s+c,[a,h]},m.javascriptGenerator.math_change=function(a){const s=m.javascriptGenerator.valueToCode(a,"DELTA",m.javascriptGenerator.ORDER_ADDITION)||"0";return a=m.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),p.NameType$$module$build$src$core$names.VARIABLE),a+" = (typeof "+a+" === 'number' ? "+a+" : 0) + "+s+`; -`},m.javascriptGenerator.math_round=m.javascriptGenerator.math_single,m.javascriptGenerator.math_trig=m.javascriptGenerator.math_single,m.javascriptGenerator.math_on_list=function(a){var s=a.getFieldValue("OP");switch(s){case"SUM":a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_MEMBER)||"[]",a+=".reduce(function(x, y) {return x + y;}, 0)";break;case"MIN":a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a="Math.min.apply(null, "+a+")";break;case"MAX":a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a="Math.max.apply(null, "+a+")";break;case"AVERAGE":s=m.javascriptGenerator.provideFunction_("mathMean",` +`)+"("+r+")":o==="DIVISIBLE_BY"?(a=m.javascriptGenerator.valueToCode(a,"DIVISOR",m.javascriptGenerator.ORDER_MODULUS)||"0",a=r+" % "+a+" === 0"):a=r+c,[a,h]},m.javascriptGenerator.math_change=function(a){const r=m.javascriptGenerator.valueToCode(a,"DELTA",m.javascriptGenerator.ORDER_ADDITION)||"0";return a=m.javascriptGenerator.nameDB_.getName(a.getFieldValue("VAR"),p.NameType$$module$build$src$core$names.VARIABLE),a+" = (typeof "+a+" === 'number' ? "+a+" : 0) + "+r+`; +`},m.javascriptGenerator.math_round=m.javascriptGenerator.math_single,m.javascriptGenerator.math_trig=m.javascriptGenerator.math_single,m.javascriptGenerator.math_on_list=function(a){var r=a.getFieldValue("OP");switch(r){case"SUM":a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_MEMBER)||"[]",a+=".reduce(function(x, y) {return x + y;}, 0)";break;case"MIN":a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a="Math.min.apply(null, "+a+")";break;case"MAX":a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a="Math.max.apply(null, "+a+")";break;case"AVERAGE":r=m.javascriptGenerator.provideFunction_("mathMean",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) { return myList.reduce(function(x, y) {return x + y;}, 0) / myList.length; } -`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=s+"("+a+")";break;case"MEDIAN":s=m.javascriptGenerator.provideFunction_("mathMedian",` +`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=r+"("+a+")";break;case"MEDIAN":r=m.javascriptGenerator.provideFunction_("mathMedian",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) { var localList = myList.filter(function (x) {return typeof x === 'number';}); if (!localList.length) return null; @@ -952,7 +952,7 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(myList) { return localList[(localList.length - 1) / 2]; } } -`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=s+"("+a+")";break;case"MODE":s=m.javascriptGenerator.provideFunction_("mathModes",` +`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=r+"("+a+")";break;case"MODE":r=m.javascriptGenerator.provideFunction_("mathModes",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(values) { var modes = []; var counts = []; @@ -981,7 +981,7 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(values) { } return modes; } -`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=s+"("+a+")";break;case"STD_DEV":s=m.javascriptGenerator.provideFunction_("mathStandardDeviation",` +`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=r+"("+a+")";break;case"STD_DEV":r=m.javascriptGenerator.provideFunction_("mathStandardDeviation",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(numbers) { var n = numbers.length; if (!n) return null; @@ -993,12 +993,12 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(numbers) { variance = variance / n; return Math.sqrt(variance); } -`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=s+"("+a+")";break;case"RANDOM":s=m.javascriptGenerator.provideFunction_("mathRandomList",` +`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=r+"("+a+")";break;case"RANDOM":r=m.javascriptGenerator.provideFunction_("mathRandomList",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(list) { var x = Math.floor(Math.random() * list.length); return list[x]; } -`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=s+"("+a+")";break;default:throw Error("Unknown operator: "+s)}return[a,m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.math_modulo=function(a){const s=m.javascriptGenerator.valueToCode(a,"DIVIDEND",m.javascriptGenerator.ORDER_MODULUS)||"0";return a=m.javascriptGenerator.valueToCode(a,"DIVISOR",m.javascriptGenerator.ORDER_MODULUS)||"0",[s+" % "+a,m.javascriptGenerator.ORDER_MODULUS]},m.javascriptGenerator.math_constrain=function(a){const s=m.javascriptGenerator.valueToCode(a,"VALUE",m.javascriptGenerator.ORDER_NONE)||"0",o=m.javascriptGenerator.valueToCode(a,"LOW",m.javascriptGenerator.ORDER_NONE)||"0";return a=m.javascriptGenerator.valueToCode(a,"HIGH",m.javascriptGenerator.ORDER_NONE)||"Infinity",["Math.min(Math.max("+s+", "+o+"), "+a+")",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.math_random_int=function(a){const s=m.javascriptGenerator.valueToCode(a,"FROM",m.javascriptGenerator.ORDER_NONE)||"0";return a=m.javascriptGenerator.valueToCode(a,"TO",m.javascriptGenerator.ORDER_NONE)||"0",[m.javascriptGenerator.provideFunction_("mathRandomInt",` +`),a=m.javascriptGenerator.valueToCode(a,"LIST",m.javascriptGenerator.ORDER_NONE)||"[]",a=r+"("+a+")";break;default:throw Error("Unknown operator: "+r)}return[a,m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.math_modulo=function(a){const r=m.javascriptGenerator.valueToCode(a,"DIVIDEND",m.javascriptGenerator.ORDER_MODULUS)||"0";return a=m.javascriptGenerator.valueToCode(a,"DIVISOR",m.javascriptGenerator.ORDER_MODULUS)||"0",[r+" % "+a,m.javascriptGenerator.ORDER_MODULUS]},m.javascriptGenerator.math_constrain=function(a){const r=m.javascriptGenerator.valueToCode(a,"VALUE",m.javascriptGenerator.ORDER_NONE)||"0",o=m.javascriptGenerator.valueToCode(a,"LOW",m.javascriptGenerator.ORDER_NONE)||"0";return a=m.javascriptGenerator.valueToCode(a,"HIGH",m.javascriptGenerator.ORDER_NONE)||"Infinity",["Math.min(Math.max("+r+", "+o+"), "+a+")",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.math_random_int=function(a){const r=m.javascriptGenerator.valueToCode(a,"FROM",m.javascriptGenerator.ORDER_NONE)||"0";return a=m.javascriptGenerator.valueToCode(a,"TO",m.javascriptGenerator.ORDER_NONE)||"0",[m.javascriptGenerator.provideFunction_("mathRandomInt",` function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(a, b) { if (a > b) { // Swap a and b to ensure a is smaller. @@ -1008,32 +1008,32 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(a, b) { } return Math.floor(Math.random() * (b - a + 1) + a); } -`)+"("+s+", "+a+")",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.math_random_float=function(a){return["Math.random()",m.javascriptGenerator.ORDER_FUNCTION_CALL]},m.javascriptGenerator.math_atan2=function(a){const s=m.javascriptGenerator.valueToCode(a,"X",m.javascriptGenerator.ORDER_NONE)||"0";return["Math.atan2("+(m.javascriptGenerator.valueToCode(a,"Y",m.javascriptGenerator.ORDER_NONE)||"0")+", "+s+") / Math.PI * 180",m.javascriptGenerator.ORDER_DIVISION]},p.NameType$$module$build$src$core$names,m.javascriptGenerator.procedures_defreturn=function(a){const s=m.javascriptGenerator.nameDB_.getName(a.getFieldValue("NAME"),p.NameType$$module$build$src$core$names.PROCEDURE);var o="";m.javascriptGenerator.STATEMENT_PREFIX&&(o+=m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_PREFIX,a)),m.javascriptGenerator.STATEMENT_SUFFIX&&(o+=m.javascriptGenerator.injectId(m.javascriptGenerator.STATEMENT_SUFFIX,a)),o&&(o=m.javascriptGenerator.prefixLines(o,m.javascriptGenerator.INDENT));let c="";m.javascriptGenerator.INFINITE_LOOP_TRAP&&(c=m.javascriptGenerator.prefixLines(m.javascriptGenerator.injectId(m.javascriptGenerator.INFINITE_LOOP_TRAP,a),m.javascriptGenerator.INDENT));const l=m.javascriptGenerator.statementToCode(a,"STACK");let h=m.javascriptGenerator.valueToCode(a,"RETURN",m.javascriptGenerator.ORDER_NONE)||"",d="";l&&h&&(d=o),h&&(h=m.javascriptGenerator.INDENT+"return "+h+`; -`);const g=[],_=a.getVars();for(let v=0;v<_.length;v++)g[v]=m.javascriptGenerator.nameDB_.getName(_[v],p.NameType$$module$build$src$core$names.VARIABLE);return o="function "+s+"("+g.join(", ")+`) { -`+o+c+l+d+h+"}",o=m.javascriptGenerator.scrub_(a,o),m.javascriptGenerator.definitions_["%"+s]=o,null},m.javascriptGenerator.procedures_defnoreturn=m.javascriptGenerator.procedures_defreturn,m.javascriptGenerator.procedures_callreturn=function(a){const s=m.javascriptGenerator.nameDB_.getName(a.getFieldValue("NAME"),p.NameType$$module$build$src$core$names.PROCEDURE),o=[],c=a.getVars();for(let l=0;lf.length)&&(C=f.length),C-=P.length;var a=f.indexOf(P,C);return a!==-1&&a===C}),String.prototype.repeat||B(String.prototype,"repeat",function(P){for(var C="",f=this;P>0;)P&1&&(C+=f),(P>>=1)&&(f+=f);return C}),String.prototype.includes||B(String.prototype,"includes",function(P,C){return this.indexOf(P,C)!=-1}),Object.assign||(Object.assign=function(P){if(P==null)throw new TypeError("Cannot convert undefined or null to object");for(var C=Object(P),f=1;f>>0,a=arguments[1],s=a>>0,o=s<0?Math.max(f+s,0):Math.min(s,f),c=arguments[2],l=c===void 0?f:c>>0,h=l<0?Math.max(f+l,0):Math.min(l,f);o0;)f&1&&(a+=C),(f>>=1)&&(C+=C);return a};var B=/^\s\s*/,P=/\s\s*$/;p.stringTrimLeft=function(C){return C.replace(B,"")},p.stringTrimRight=function(C){return C.replace(P,"")},p.copyObject=function(C){var f={};for(var a in C)f[a]=C[a];return f},p.copyArray=function(C){for(var f=[],a=0,s=C.length;a=0?parseFloat((C.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]):parseFloat((C.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]),p.isOldIE=p.isIE&&p.isIE<9,p.isGecko=p.isMozilla=C.match(/ Gecko\/\d+/),p.isOpera=typeof opera=="object"&&Object.prototype.toString.call(window.opera)=="[object Opera]",p.isWebKit=parseFloat(C.split("WebKit/")[1])||void 0,p.isChrome=parseFloat(C.split(" Chrome/")[1])||void 0,p.isEdge=parseFloat(C.split(" Edge/")[1])||void 0,p.isAIR=C.indexOf("AdobeAIR")>=0,p.isAndroid=C.indexOf("Android")>=0,p.isChromeOS=C.indexOf(" CrOS ")>=0,p.isIOS=/iPad|iPhone|iPod/.test(C)&&!window.MSStream,p.isIOS&&(p.isMac=!0),p.isMobile=p.isIOS||p.isAndroid}),ace.define("ace/lib/dom",["require","exports","module","ace/lib/useragent"],function(r,p,m){var B=r("./useragent"),P="http://www.w3.org/1999/xhtml";p.buildDom=function c(l,h,d){if(typeof l=="string"&&l){var g=document.createTextNode(l);return h&&h.appendChild(g),g}if(!Array.isArray(l))return l&&l.appendChild&&h&&h.appendChild(l),l;if(typeof l[0]!="string"||!l[0]){for(var _=[],v=0;v"u")){if(f){if(h)a();else if(h===!1)return f.push([c,l])}if(!C){var d=h;!h||!h.getRootNode?d=document:(d=h.getRootNode(),(!d||d==h)&&(d=document));var g=d.ownerDocument||d;if(l&&p.hasCssString(l,d))return null;l&&(c+=` -/*# sourceURL=ace/css/`+l+" */");var _=p.createElement("style");_.appendChild(g.createTextNode(c)),l&&(_.id=l),d==g&&(d=p.getDocumentHead(g)),d.insertBefore(_,d.firstChild)}}}if(p.importCssString=s,p.importCssStylsheet=function(c,l){p.buildDom(["link",{rel:"stylesheet",href:c}],p.getDocumentHead(l))},p.scrollbarWidth=function(c){var l=p.createElement("ace_inner");l.style.width="100%",l.style.minWidth="0px",l.style.height="200px",l.style.display="block";var h=p.createElement("ace_outer"),d=h.style;d.position="absolute",d.left="-10000px",d.overflow="hidden",d.width="200px",d.minWidth="0px",d.height="150px",d.display="block",h.appendChild(l);var g=c&&c.documentElement||document&&document.documentElement;if(!g)return 0;g.appendChild(h);var _=l.offsetWidth;d.overflow="scroll";var v=l.offsetWidth;return _===v&&(v=h.clientWidth),g.removeChild(h),_-v},p.computedStyle=function(c,l){return window.getComputedStyle(c,"")||{}},p.setStyle=function(c,l,h){c[l]!==h&&(c[l]=h)},p.HAS_CSS_ANIMATION=!1,p.HAS_CSS_TRANSFORMS=!1,p.HI_DPI=B.isWin?typeof window<"u"&&window.devicePixelRatio>=1.5:!0,B.isChromeOS&&(p.HI_DPI=!1),typeof document<"u"){var o=document.createElement("div");p.HI_DPI&&o.style.transform!==void 0&&(p.HAS_CSS_TRANSFORMS=!0),!B.isEdge&&typeof o.style.animationName<"u"&&(p.HAS_CSS_ANIMATION=!0),o=null}p.HAS_CSS_TRANSFORMS?p.translate=function(c,l,h){c.style.transform="translate("+Math.round(l)+"px, "+Math.round(h)+"px)"}:p.translate=function(c,l,h){c.style.top=Math.round(h)+"px",c.style.left=Math.round(l)+"px"}}),ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"],function(r,p,m){/* + */return s})})(Tm);var G_=Tm.exports;const ri=vm(G_);bm();const ym=ri.Theme.defineTheme("themeName",{base:ri.Themes.Classic,blockStyles:{loop_blocks:{colourPrimary:"#0361FF"},array_blocks:{colourPrimary:"#FA0000"},logic_blocks:{colourPrimary:"#00D084"},class_blocks:{colourPrimary:"#6381fe"},comment_blocks:{colourPrimary:"#808080"},procedure_blocks:{colourPrimary:"#5300EB"},variable_blocks:{colourPrimary:"#f80069"},expression_blocks:{colourPrimary:"#a7ca00"},parameter_blocks:{colourPrimary:"#8F48B7"}},categoryStyles:{loop_blocks:{colour:"#395BBF"},procedure_blocks:{colour:"#FF6600"},logic_blocks:{colour:"#00D084"},class_blocks:{colour:"#6381fe"},comment_blocks:{colour:"#808080"},array_blocks:{colour:"#C200F1"},variable_blocks:{colour:"#f80069"},expression_blocks:{colour:"#a7ca00"}}}),U_=ri.Theme.defineTheme("PraxlyDark",{base:ri.Themes.Classic,blockStyles:{loop_blocks:{colourPrimary:"#0361FF"},array_blocks:{colourPrimary:"#FA0000"},logic_blocks:{colourPrimary:"#00D084"},class_blocks:{colourPrimary:"#6381fe"},comment_blocks:{colourPrimary:"#808080"},procedure_blocks:{colourPrimary:"#5300EB"},variable_blocks:{colourPrimary:"#f80069"},expression_blocks:{colourPrimary:"#a7ca00"},parameter_blocks:{colourPrimary:"#8F48B7"}},categoryStyles:{loop_blocks:{colour:"#395BBF"},procedure_blocks:{colour:"#FF6600"},logic_blocks:{colour:"#00D084"},class_blocks:{colour:"#6381fe"},comment_blocks:{colour:"#808080"},array_blocks:{colour:"#C200F1"},variable_blocks:{colour:"#f80069"},expression_blocks:{colour:"#a7ca00"}},componentStyles:{workspaceBackgroundColour:"#1e1e1e",toolboxBackgroundColour:"blackBackground",toolboxForegroundColour:"#fff",flyoutBackgroundColour:"#252526",flyoutForegroundColour:"#ccc",flyoutOpacity:1,scrollbarColour:"#797979",insertionMarkerColour:"#fff",insertionMarkerOpacity:.3,scrollbarOpacity:.4,cursorColour:"#d0d0d0",blackBackground:"#333"}}),H_={kind:"categoryToolbox",contents:[{kind:"category",name:"common",categorystyle:"array_blocks",contents:[{kind:"block",type:"praxly_comment_block"},{kind:"block",type:"praxly_single_line_comment_block"},{kind:"block",type:"praxly_print_block",inputs:{EXPRESSION:{shadow:{type:"praxly_literal_block",fields:{LITERAL:'"hello, world"'}}}}},{kind:"block",type:"praxly_statement_block",inputs:{EXPRESSION:{shadow:{type:"praxly_literal_block",fields:{LITERAL:"expression"}}}}}]},{kind:"category",name:"expressions",categorystyle:"expression_blocks",contents:[{kind:"block",type:"praxly_literal_block"},{kind:"block",type:"praxly_arithmetic_block",inputs:{A_OPERAND:{shadow:{type:"praxly_literal_block",fields:{LITERAL:1}}},B_OPERAND:{shadow:{type:"praxly_literal_block",fields:{LITERAL:1}}}}},{kind:"block",type:"praxly_null_block"},{kind:"block",type:"praxly_true_block"},{kind:"block",type:"praxly_false_block"}]},{kind:"category",name:"variables",categorystyle:"variable_blocks",contents:[{kind:"block",type:"praxly_assignment_block"},{kind:"block",type:"praxly_reassignment_block"},{kind:"block",type:"praxly_variable_block"},{kind:"block",type:"praxly_array_assignment_block",inputs:{EXPRESSION:{block:{type:"praxly_parameter_block"}}}},{kind:"block",type:"praxly_array_reference_block",inputs:{INDEX:{shadow:{type:"praxly_literal_block",fields:{LITERAL:"0"}}}}},{kind:"block",type:"praxly_array_reference_reassignment_block",inputs:{INDEX:{shadow:{type:"praxly_literal_block",fields:{LITERAL:"0"}}}}}]},{kind:"category",name:"logic",categorystyle:"logic_blocks",contents:[{kind:"block",type:"praxly_if_block"},{kind:"block",type:"praxly_if_else_block"},{kind:"block",type:"praxly_boolean_operators_block",inputs:{A_OPERAND:{shadow:{type:"praxly_literal_block",fields:{LITERAL:!0}}},B_OPERAND:{shadow:{type:"praxly_literal_block",fields:{LITERAL:!1}}}}},{kind:"block",type:"praxly_not_block"},{kind:"block",type:"praxly_compare_block",inputs:{A_OPERAND:{shadow:{type:"praxly_literal_block",fields:{LITERAL:1}}},B_OPERAND:{shadow:{type:"praxly_literal_block",fields:{LITERAL:1}}}}}]},{kind:"category",name:"loops",categorystyle:"loop_blocks",contents:[{kind:"block",type:"praxly_for_loop_block",inputs:{INITIALIZATION:{block:{type:"praxly_assignment_expression_block",inputs:{EXPRESSION:{shadow:{type:"praxly_literal_block",fields:{LITERAL:"0"}}}}}},CONDITION:{block:{type:"praxly_compare_block",inputs:{A_OPERAND:{block:{type:"praxly_literal_block",fields:{LITERAL:"i"}}},B_OPERAND:{block:{type:"praxly_literal_block",fields:{LITERAL:1}}}},fields:{OPERATOR:"LESS_THAN"}}},REASSIGNMENT:{block:{type:"praxly_reassignment_expression_block",inputs:{EXPRESSION:{block:{type:"praxly_arithmetic_block",inputs:{A_OPERAND:{shadow:{type:"praxly_variable_block",fields:{LITERAL:"i"}}},B_OPERAND:{shadow:{type:"praxly_literal_block",fields:{LITERAL:1}}}}}}}}}}},{kind:"block",type:"praxly_while_loop_block"},{kind:"block",type:"praxly_do_while_loop_block"},{kind:"block",type:"praxly_repeat_until_loop_block"}]},{kind:"category",name:"procedures",categorystyle:"procedure_blocks",contents:[{kind:"block",type:"praxly_procedure_block",inputs:{PARAMS:{block:{type:"praxly_parameter_block"}}}},{kind:"block",type:"praxly_function_call_block",inputs:{PARAMS:{block:{type:"praxly_parameter_block"}}}},{kind:"block",type:"praxly_return_block"},{kind:"block",type:"praxly_print_block",inputs:{EXPRESSION:{shadow:{type:"praxly_literal_block",fields:{LITERAL:'"hello, world"'}}}}},{kind:"block",type:"praxly_singular_param_block"}]}]};var wm={exports:{}};(function(T,$){(function(){var s="ace",p=function(){return this}();!p&&typeof window<"u"&&(p=window);var m=function(r,o,c){if(typeof r!="string"){m.original?m.original.apply(this,arguments):(console.error("dropping module because define wasn't a string."),console.trace());return}arguments.length==2&&(c=o),m.modules[r]||(m.payloads[r]=c,m.modules[r]=null)};m.modules={},m.payloads={};var B=function(r,o,c){if(typeof o=="string"){var l=f(r,o);if(l!=null)return c&&c(),l}else if(Object.prototype.toString.call(o)==="[object Array]"){for(var h=[],d=0,g=o.length;df.length)&&(C=f.length),C-=P.length;var a=f.indexOf(P,C);return a!==-1&&a===C}),String.prototype.repeat||B(String.prototype,"repeat",function(P){for(var C="",f=this;P>0;)P&1&&(C+=f),(P>>=1)&&(f+=f);return C}),String.prototype.includes||B(String.prototype,"includes",function(P,C){return this.indexOf(P,C)!=-1}),Object.assign||(Object.assign=function(P){if(P==null)throw new TypeError("Cannot convert undefined or null to object");for(var C=Object(P),f=1;f>>0,a=arguments[1],r=a>>0,o=r<0?Math.max(f+r,0):Math.min(r,f),c=arguments[2],l=c===void 0?f:c>>0,h=l<0?Math.max(f+l,0):Math.min(l,f);o0;)f&1&&(a+=C),(f>>=1)&&(C+=C);return a};var B=/^\s\s*/,P=/\s\s*$/;p.stringTrimLeft=function(C){return C.replace(B,"")},p.stringTrimRight=function(C){return C.replace(P,"")},p.copyObject=function(C){var f={};for(var a in C)f[a]=C[a];return f},p.copyArray=function(C){for(var f=[],a=0,r=C.length;a=0?parseFloat((C.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]):parseFloat((C.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]),p.isOldIE=p.isIE&&p.isIE<9,p.isGecko=p.isMozilla=C.match(/ Gecko\/\d+/),p.isOpera=typeof opera=="object"&&Object.prototype.toString.call(window.opera)=="[object Opera]",p.isWebKit=parseFloat(C.split("WebKit/")[1])||void 0,p.isChrome=parseFloat(C.split(" Chrome/")[1])||void 0,p.isEdge=parseFloat(C.split(" Edge/")[1])||void 0,p.isAIR=C.indexOf("AdobeAIR")>=0,p.isAndroid=C.indexOf("Android")>=0,p.isChromeOS=C.indexOf(" CrOS ")>=0,p.isIOS=/iPad|iPhone|iPod/.test(C)&&!window.MSStream,p.isIOS&&(p.isMac=!0),p.isMobile=p.isIOS||p.isAndroid}),ace.define("ace/lib/dom",["require","exports","module","ace/lib/useragent"],function(s,p,m){var B=s("./useragent"),P="http://www.w3.org/1999/xhtml";p.buildDom=function c(l,h,d){if(typeof l=="string"&&l){var g=document.createTextNode(l);return h&&h.appendChild(g),g}if(!Array.isArray(l))return l&&l.appendChild&&h&&h.appendChild(l),l;if(typeof l[0]!="string"||!l[0]){for(var _=[],v=0;v"u")){if(f){if(h)a();else if(h===!1)return f.push([c,l])}if(!C){var d=h;!h||!h.getRootNode?d=document:(d=h.getRootNode(),(!d||d==h)&&(d=document));var g=d.ownerDocument||d;if(l&&p.hasCssString(l,d))return null;l&&(c+=` +/*# sourceURL=ace/css/`+l+" */");var _=p.createElement("style");_.appendChild(g.createTextNode(c)),l&&(_.id=l),d==g&&(d=p.getDocumentHead(g)),d.insertBefore(_,d.firstChild)}}}if(p.importCssString=r,p.importCssStylsheet=function(c,l){p.buildDom(["link",{rel:"stylesheet",href:c}],p.getDocumentHead(l))},p.scrollbarWidth=function(c){var l=p.createElement("ace_inner");l.style.width="100%",l.style.minWidth="0px",l.style.height="200px",l.style.display="block";var h=p.createElement("ace_outer"),d=h.style;d.position="absolute",d.left="-10000px",d.overflow="hidden",d.width="200px",d.minWidth="0px",d.height="150px",d.display="block",h.appendChild(l);var g=c&&c.documentElement||document&&document.documentElement;if(!g)return 0;g.appendChild(h);var _=l.offsetWidth;d.overflow="scroll";var v=l.offsetWidth;return _===v&&(v=h.clientWidth),g.removeChild(h),_-v},p.computedStyle=function(c,l){return window.getComputedStyle(c,"")||{}},p.setStyle=function(c,l,h){c[l]!==h&&(c[l]=h)},p.HAS_CSS_ANIMATION=!1,p.HAS_CSS_TRANSFORMS=!1,p.HI_DPI=B.isWin?typeof window<"u"&&window.devicePixelRatio>=1.5:!0,B.isChromeOS&&(p.HI_DPI=!1),typeof document<"u"){var o=document.createElement("div");p.HI_DPI&&o.style.transform!==void 0&&(p.HAS_CSS_TRANSFORMS=!0),!B.isEdge&&typeof o.style.animationName<"u"&&(p.HAS_CSS_ANIMATION=!0),o=null}p.HAS_CSS_TRANSFORMS?p.translate=function(c,l,h){c.style.transform="translate("+Math.round(l)+"px, "+Math.round(h)+"px)"}:p.translate=function(c,l,h){c.style.top=Math.round(h)+"px",c.style.left=Math.round(l)+"px"}}),ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"],function(s,p,m){/* * based on code from: * * @license RequireJS text 0.25.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved. * Available via the MIT or new BSD license. * see: http://github.com/jrburke/requirejs for details -*/var B=r("./dom");p.get=function(P,C){var f=new XMLHttpRequest;f.open("GET",P,!0),f.onreadystatechange=function(){f.readyState===4&&C(f.responseText)},f.send(null)},p.loadScript=function(P,C){var f=B.getDocumentHead(),a=document.createElement("script");a.src=P,f.appendChild(a),a.onload=a.onreadystatechange=function(s,o){(o||!a.readyState||a.readyState=="loaded"||a.readyState=="complete")&&(a=a.onload=a.onreadystatechange=null,o||C())}},p.qualifyURL=function(P){var C=document.createElement("a");return C.href=P,C.href}}),ace.define("ace/lib/oop",["require","exports","module"],function(r,p,m){p.inherits=function(B,P){B.super_=P,B.prototype=Object.create(P.prototype,{constructor:{value:B,enumerable:!1,writable:!0,configurable:!0}})},p.mixin=function(B,P){for(var C in P)B[C]=P[C];return B},p.implement=function(B,P){p.mixin(B,P)}}),ace.define("ace/lib/event_emitter",["require","exports","module"],function(r,p,m){var B={},P=function(){this.propagationStopped=!0},C=function(){this.defaultPrevented=!0};B._emit=B._dispatchEvent=function(f,a){this._eventRegistry||(this._eventRegistry={}),this._defaultHandlers||(this._defaultHandlers={});var s=this._eventRegistry[f]||[],o=this._defaultHandlers[f];if(!(!s.length&&!o)){(typeof a!="object"||!a)&&(a={}),a.type||(a.type=f),a.stopPropagation||(a.stopPropagation=P),a.preventDefault||(a.preventDefault=C),s=s.slice();for(var c=0;c1&&(g=h[h.length-2]);var v=a[l+"Path"];return v==null?v=a.basePath:d=="/"&&(l=d=""),v&&v.slice(-1)!="/"&&(v+="/"),v+l+d+g+this.get("suffix")},p.setModuleUrl=function(c,l){return a.$moduleUrls[c]=l};var s=function(c,l){return c==="ace/theme/textmate"||c==="./theme/textmate"?l(null,r("./theme/textmate")):console.error("loader is not configured")};p.setLoader=function(c){s=c},p.dynamicModules=Object.create(null),p.$loading={},p.loadModule=function(c,l){var h,d;Array.isArray(c)&&(d=c[0],c=c[1]);var g=function(_){if(_&&!p.$loading[c])return l&&l(_);if(p.$loading[c]||(p.$loading[c]=[]),p.$loading[c].push(l),!(p.$loading[c].length>1)){var v=function(){s(c,function(k,I){p._emit("load.module",{name:c,module:I});var S=p.$loading[c];p.$loading[c]=null,S.forEach(function(b){b&&b(I)})})};if(!p.get("packaged"))return v();P.loadScript(p.moduleUrl(c,d),v),o()}};if(p.dynamicModules[c])p.dynamicModules[c]().then(function(_){_.default?g(_.default):g(_)});else{try{h=r(c)}catch{}g(h)}},p.setModuleLoader=function(c,l){p.dynamicModules[c]=l};var o=function(){!a.basePath&&!a.workerPath&&!a.modePath&&!a.themePath&&!Object.keys(a.$moduleUrls).length&&(console.error("Unable to infer path to ace from script src,","use ace.config.set('basePath', 'path') to enable dynamic loading of modes and themes","or with webpack use ace/webpack-resolver"),o=function(){})};p.version="1.22.0"}),ace.define("ace/loader_build",["require","exports","module","ace/lib/fixoldbrowsers","ace/config"],function(r,p,m){r("./lib/fixoldbrowsers");var B=r("./config");B.setLoader(function(a,s){r([a],function(o){s(null,o)})});var P=function(){return this||typeof window<"u"&&window}();m.exports=function(a){B.init=C,a.require=r},C(!0);function C(a){if(!(!P||!P.document)){B.set("packaged",a||r.packaged||m.packaged||P.define&&(void 0).packaged);var s={},o="",c=document.currentScript||document._currentScript,l=c&&c.ownerDocument||document;c&&c.src&&(o=c.src.split(/[?#]/)[0].split("/").slice(0,-1).join("/")||"");for(var h=l.getElementsByTagName("script"),d=0;d ["+this.end.row+"/"+this.end.column+"]"},C.prototype.contains=function(f,a){return this.compare(f,a)==0},C.prototype.compareRange=function(f){var a,s=f.end,o=f.start;return a=this.compare(s.row,s.column),a==1?(a=this.compare(o.row,o.column),a==1?2:a==0?1:0):a==-1?-2:(a=this.compare(o.row,o.column),a==-1?-1:a==1?42:0)},C.prototype.comparePoint=function(f){return this.compare(f.row,f.column)},C.prototype.containsRange=function(f){return this.comparePoint(f.start)==0&&this.comparePoint(f.end)==0},C.prototype.intersects=function(f){var a=this.compareRange(f);return a==-1||a==0||a==1},C.prototype.isEnd=function(f,a){return this.end.row==f&&this.end.column==a},C.prototype.isStart=function(f,a){return this.start.row==f&&this.start.column==a},C.prototype.setStart=function(f,a){typeof f=="object"?(this.start.column=f.column,this.start.row=f.row):(this.start.row=f,this.start.column=a)},C.prototype.setEnd=function(f,a){typeof f=="object"?(this.end.column=f.column,this.end.row=f.row):(this.end.row=f,this.end.column=a)},C.prototype.inside=function(f,a){return this.compare(f,a)==0?!(this.isEnd(f,a)||this.isStart(f,a)):!1},C.prototype.insideStart=function(f,a){return this.compare(f,a)==0?!this.isEnd(f,a):!1},C.prototype.insideEnd=function(f,a){return this.compare(f,a)==0?!this.isStart(f,a):!1},C.prototype.compare=function(f,a){return!this.isMultiLine()&&f===this.start.row?athis.end.column?1:0:fthis.end.row?1:this.start.row===f?a>=this.start.column?0:-1:this.end.row===f?a<=this.end.column?0:1:0},C.prototype.compareStart=function(f,a){return this.start.row==f&&this.start.column==a?-1:this.compare(f,a)},C.prototype.compareEnd=function(f,a){return this.end.row==f&&this.end.column==a?1:this.compare(f,a)},C.prototype.compareInside=function(f,a){return this.end.row==f&&this.end.column==a?1:this.start.row==f&&this.start.column==a?-1:this.compare(f,a)},C.prototype.clipRows=function(f,a){if(this.end.row>a)var s={row:a+1,column:0};else if(this.end.rowa)var o={row:a+1,column:0};else if(this.start.row1&&(g=h[h.length-2]);var v=a[l+"Path"];return v==null?v=a.basePath:d=="/"&&(l=d=""),v&&v.slice(-1)!="/"&&(v+="/"),v+l+d+g+this.get("suffix")},p.setModuleUrl=function(c,l){return a.$moduleUrls[c]=l};var r=function(c,l){return c==="ace/theme/textmate"||c==="./theme/textmate"?l(null,s("./theme/textmate")):console.error("loader is not configured")};p.setLoader=function(c){r=c},p.dynamicModules=Object.create(null),p.$loading={},p.loadModule=function(c,l){var h,d;Array.isArray(c)&&(d=c[0],c=c[1]);var g=function(_){if(_&&!p.$loading[c])return l&&l(_);if(p.$loading[c]||(p.$loading[c]=[]),p.$loading[c].push(l),!(p.$loading[c].length>1)){var v=function(){r(c,function(M,y){p._emit("load.module",{name:c,module:y});var I=p.$loading[c];p.$loading[c]=null,I.forEach(function(w){w&&w(y)})})};if(!p.get("packaged"))return v();P.loadScript(p.moduleUrl(c,d),v),o()}};if(p.dynamicModules[c])p.dynamicModules[c]().then(function(_){_.default?g(_.default):g(_)});else{try{h=s(c)}catch{}g(h)}},p.setModuleLoader=function(c,l){p.dynamicModules[c]=l};var o=function(){!a.basePath&&!a.workerPath&&!a.modePath&&!a.themePath&&!Object.keys(a.$moduleUrls).length&&(console.error("Unable to infer path to ace from script src,","use ace.config.set('basePath', 'path') to enable dynamic loading of modes and themes","or with webpack use ace/webpack-resolver"),o=function(){})};p.version="1.22.0"}),ace.define("ace/loader_build",["require","exports","module","ace/lib/fixoldbrowsers","ace/config"],function(s,p,m){s("./lib/fixoldbrowsers");var B=s("./config");B.setLoader(function(a,r){s([a],function(o){r(null,o)})});var P=function(){return this||typeof window<"u"&&window}();m.exports=function(a){B.init=C,a.require=s},C(!0);function C(a){if(!(!P||!P.document)){B.set("packaged",a||s.packaged||m.packaged||P.define&&(void 0).packaged);var r={},o="",c=document.currentScript||document._currentScript,l=c&&c.ownerDocument||document;c&&c.src&&(o=c.src.split(/[?#]/)[0].split("/").slice(0,-1).join("/")||"");for(var h=l.getElementsByTagName("script"),d=0;d ["+this.end.row+"/"+this.end.column+"]"},C.prototype.contains=function(f,a){return this.compare(f,a)==0},C.prototype.compareRange=function(f){var a,r=f.end,o=f.start;return a=this.compare(r.row,r.column),a==1?(a=this.compare(o.row,o.column),a==1?2:a==0?1:0):a==-1?-2:(a=this.compare(o.row,o.column),a==-1?-1:a==1?42:0)},C.prototype.comparePoint=function(f){return this.compare(f.row,f.column)},C.prototype.containsRange=function(f){return this.comparePoint(f.start)==0&&this.comparePoint(f.end)==0},C.prototype.intersects=function(f){var a=this.compareRange(f);return a==-1||a==0||a==1},C.prototype.isEnd=function(f,a){return this.end.row==f&&this.end.column==a},C.prototype.isStart=function(f,a){return this.start.row==f&&this.start.column==a},C.prototype.setStart=function(f,a){typeof f=="object"?(this.start.column=f.column,this.start.row=f.row):(this.start.row=f,this.start.column=a)},C.prototype.setEnd=function(f,a){typeof f=="object"?(this.end.column=f.column,this.end.row=f.row):(this.end.row=f,this.end.column=a)},C.prototype.inside=function(f,a){return this.compare(f,a)==0?!(this.isEnd(f,a)||this.isStart(f,a)):!1},C.prototype.insideStart=function(f,a){return this.compare(f,a)==0?!this.isEnd(f,a):!1},C.prototype.insideEnd=function(f,a){return this.compare(f,a)==0?!this.isStart(f,a):!1},C.prototype.compare=function(f,a){return!this.isMultiLine()&&f===this.start.row?athis.end.column?1:0:fthis.end.row?1:this.start.row===f?a>=this.start.column?0:-1:this.end.row===f?a<=this.end.column?0:1:0},C.prototype.compareStart=function(f,a){return this.start.row==f&&this.start.column==a?-1:this.compare(f,a)},C.prototype.compareEnd=function(f,a){return this.end.row==f&&this.end.column==a?1:this.compare(f,a)},C.prototype.compareInside=function(f,a){return this.end.row==f&&this.end.column==a?1:this.start.row==f&&this.start.column==a?-1:this.compare(f,a)},C.prototype.clipRows=function(f,a){if(this.end.row>a)var r={row:a+1,column:0};else if(this.end.rowa)var o={row:a+1,column:0};else if(this.start.row1?(N++,N>4&&(N=1)):N=1,P.isIE){var L=Math.abs(T.clientX-D)>5||Math.abs(T.clientY-R)>5;(!w||L)&&(N=1),w&&clearTimeout(w),w=setTimeout(function(){w=null},I[N-1]||600),N==1&&(D=T.clientX,R=T.clientY)}if(T._clicks=N,S[b]("mousedown",T),N>4)N=0;else if(N>1)return S[b](F[N],T)}Array.isArray(k)||(k=[k]),k.forEach(function(T){l(T,"mousedown",A,x)})};var d=function(k){return 0|(k.ctrlKey?1:0)|(k.altKey?2:0)|(k.shiftKey?4:0)|(k.metaKey?8:0)};p.getModifierString=function(k){return B.KEY_MODS[d(k)]};function g(k,I,S){var b=d(I);if(!P.isMac&&C){if(I.getModifierState&&(I.getModifierState("OS")||I.getModifierState("Win"))&&(b|=8),C.altGr)if((3&b)!=3)C.altGr=0;else return;if(S===18||S===17){var x="location"in I?I.location:I.keyLocation;if(S===17&&x===1)C[S]==1&&(f=I.timeStamp);else if(S===18&&b===3&&x===2){var N=I.timeStamp-f;N<50&&(C.altGr=!0)}}}if(S in B.MODIFIER_KEYS&&(S=-1),!b&&S===13){var x="location"in I?I.location:I.keyLocation;if(x===3&&(k(I,b,-S),I.defaultPrevented))return}if(P.isChromeOS&&b&8){if(k(I,b,S),I.defaultPrevented)return;b&=-9}return!b&&!(S in B.FUNCTION_KEYS)&&!(S in B.PRINTABLE_KEYS)?!1:k(I,b,S)}p.addCommandKeyListener=function(k,I,S){if(P.isOldGecko||P.isOpera&&!("KeyboardEvent"in window)){var b=null;l(k,"keydown",function(N){b=N.keyCode},S),l(k,"keypress",function(N){return g(I,N,b)},S)}else{var x=null;l(k,"keydown",function(N){C[N.keyCode]=(C[N.keyCode]||0)+1;var D=g(I,N,N.keyCode);return x=N.defaultPrevented,D},S),l(k,"keypress",function(N){x&&(N.ctrlKey||N.altKey||N.shiftKey||N.metaKey)&&(p.stopEvent(N),x=null)},S),l(k,"keyup",function(N){C[N.keyCode]=null},S),C||(_(),l(window,"focus",_))}};function _(){C=Object.create(null)}if(typeof window=="object"&&window.postMessage&&!P.isOldIE){var v=1;p.nextTick=function(k,I){I=I||window;var S="zero-timeout-message-"+v++,b=function(x){x.data==S&&(p.stopPropagation(x),h(I,"message",b),k())};l(I,"message",b),I.postMessage(S,"*")}}p.$idleBlocked=!1,p.onIdle=function(k,I){return setTimeout(function S(){p.$idleBlocked?setTimeout(S,100):k()},I)},p.$idleBlockId=null,p.blockIdle=function(k){p.$idleBlockId&&clearTimeout(p.$idleBlockId),p.$idleBlocked=!0,p.$idleBlockId=setTimeout(function(){p.$idleBlocked=!1},k||100)},p.nextFrame=typeof window=="object"&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame),p.nextFrame?p.nextFrame=p.nextFrame.bind(window):p.nextFrame=function(k){setTimeout(k,17)}}),ace.define("ace/clipboard",["require","exports","module"],function(r,p,m){var B;m.exports={lineMode:!1,pasteCancelled:function(){return B&&B>Date.now()-50?!0:B=!1},cancel:function(){B=Date.now()}}}),ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/config","ace/lib/useragent","ace/lib/dom","ace/lib/lang","ace/clipboard","ace/lib/keys"],function(r,p,m){var B=r("../lib/event"),P=r("../config").nls,C=r("../lib/useragent"),f=r("../lib/dom"),a=r("../lib/lang"),s=r("../clipboard"),o=C.isChrome<18,c=C.isIE,l=C.isChrome>63,h=400,d=r("../lib/keys"),g=d.KEY_MODS,_=C.isIOS,v=_?/\s/:/\n/,k=C.isMobile,I=function(S,b){var x=f.createElement("textarea");x.className="ace_text-input",x.setAttribute("wrap","off"),x.setAttribute("autocorrect","off"),x.setAttribute("autocapitalize","off"),x.setAttribute("spellcheck",!1),x.style.opacity="0",S.insertBefore(x,S.firstChild);var N=!1,D=!1,R=!1,w=!1,F="";k||(x.style.fontSize="1px");var A=!1,T=!1,L="",O=0,H=0,V=0;try{var W=document.activeElement===x}catch{}this.setAriaOptions=function(ae){ae.activeDescendant?(x.setAttribute("aria-haspopup","true"),x.setAttribute("aria-autocomplete",ae.inline?"both":"list"),x.setAttribute("aria-activedescendant",ae.activeDescendant)):(x.setAttribute("aria-haspopup","false"),x.setAttribute("aria-autocomplete","both"),x.removeAttribute("aria-activedescendant")),ae.role&&x.setAttribute("role",ae.role)},this.setAriaLabel=function(){if(b.session&&b.renderer.enableKeyboardAccessibility){var ae=b.session.selection.cursor.row;x.setAttribute("aria-roledescription",P("editor")),x.setAttribute("aria-label",P("Cursor at row $0",[ae+1]))}else x.removeAttribute("aria-roledescription"),x.removeAttribute("aria-label")},this.setAriaOptions({role:"textbox"}),this.setAriaLabel(),B.addListener(x,"blur",function(ae){T||(b.onBlur(ae),W=!1,k&&!_&&document.removeEventListener("selectionchange",J))},b),B.addListener(x,"focus",function(ae){if(!T){if(W=!0,C.isEdge)try{if(!document.hasFocus())return}catch{}b.onFocus(ae),C.isEdge?setTimeout(K):K(),k&&!_&&document.addEventListener("selectionchange",J)}},b),this.$focusScroll=!1,this.focus=function(){if(this.setAriaLabel(),F||l||this.$focusScroll=="browser")return x.focus({preventScroll:!0});var ae=x.style.top;x.style.position="fixed",x.style.top="0px";try{var ue=x.getBoundingClientRect().top!=0}catch{return}var be=[];if(ue)for(var Ne=x.parentElement;Ne&&Ne.nodeType==1;)be.push(Ne),Ne.setAttribute("ace_nocontext",!0),!Ne.parentElement&&Ne.getRootNode?Ne=Ne.getRootNode().host:Ne=Ne.parentElement;x.focus({preventScroll:!0}),ue&&be.forEach(function(Be){Be.removeAttribute("ace_nocontext")}),setTimeout(function(){x.style.position="",x.style.top=="0px"&&(x.style.top=ae)},0)},this.blur=function(){x.blur()},this.isFocused=function(){return W},b.on("beforeEndOperation",function(){var ae=b.curOp,ue=ae&&ae.command&&ae.command.name;if(ue!="insertstring"){var be=ue&&(ae.docChanged||ae.selectionChanged);R&&be&&(L=x.value="",Ue()),K()}});var K=_?function(ae){if(!(!W||N&&!ae||w)){ae||(ae="");var ue=` + @license */var B=s("./oop"),P=function(){var C={MODIFIER_KEYS:{16:"Shift",17:"Ctrl",18:"Alt",224:"Meta",91:"MetaLeft",92:"MetaRight",93:"ContextMenu"},KEY_MODS:{ctrl:1,alt:2,option:2,shift:4,super:8,meta:8,command:8,cmd:8,control:1},FUNCTION_KEYS:{8:"Backspace",9:"Tab",13:"Return",19:"Pause",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"Print",45:"Insert",46:"Delete",96:"Numpad0",97:"Numpad1",98:"Numpad2",99:"Numpad3",100:"Numpad4",101:"Numpad5",102:"Numpad6",103:"Numpad7",104:"Numpad8",105:"Numpad9","-13":"NumpadEnter",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"Numlock",145:"Scrolllock"},PRINTABLE_KEYS:{32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",61:"=",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",107:"+",109:"-",110:".",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",111:"/",106:"*"}};C.PRINTABLE_KEYS[173]="-";var f,a;for(a in C.FUNCTION_KEYS)f=C.FUNCTION_KEYS[a].toLowerCase(),C[f]=parseInt(a,10);for(a in C.PRINTABLE_KEYS)f=C.PRINTABLE_KEYS[a].toLowerCase(),C[f]=parseInt(a,10);return B.mixin(C,C.MODIFIER_KEYS),B.mixin(C,C.PRINTABLE_KEYS),B.mixin(C,C.FUNCTION_KEYS),C.enter=C.return,C.escape=C.esc,C.del=C.delete,function(){for(var r=["cmd","ctrl","alt","shift"],o=Math.pow(2,r.length);o--;)C.KEY_MODS[o]=r.filter(function(c){return o&C.KEY_MODS[c]}).join("-")+"-"}(),C.KEY_MODS[0]="",C.KEY_MODS[-1]="input-",C}();B.mixin(p,P),p.keyCodeToString=function(C){var f=P[C];return typeof f!="string"&&(f=String.fromCharCode(C)),f.toLowerCase()}}),ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(s,p,m){var B=s("./keys"),P=s("./useragent"),C=null,f=0,a;function r(){a=!1;try{document.createComment("").addEventListener("test",function(){},{get passive(){a={passive:!1}}})}catch{}}function o(){return a==null&&r(),a}function c(M,y,I){this.elem=M,this.type=y,this.callback=I}c.prototype.destroy=function(){h(this.elem,this.type,this.callback),this.elem=this.type=this.callback=void 0};var l=p.addListener=function(M,y,I,w){M.addEventListener(y,I,o()),w&&w.$toDestroy.push(new c(M,y,I))},h=p.removeListener=function(M,y,I){M.removeEventListener(y,I,o())};p.stopEvent=function(M){return p.stopPropagation(M),p.preventDefault(M),!1},p.stopPropagation=function(M){M.stopPropagation&&M.stopPropagation()},p.preventDefault=function(M){M.preventDefault&&M.preventDefault()},p.getButton=function(M){return M.type=="dblclick"?0:M.type=="contextmenu"||P.isMac&&M.ctrlKey&&!M.altKey&&!M.shiftKey?2:M.button},p.capture=function(M,y,I){var w=M&&M.ownerDocument||document;function x(N){y&&y(N),I&&I(N),h(w,"mousemove",y),h(w,"mouseup",x),h(w,"dragstart",x)}return l(w,"mousemove",y),l(w,"mouseup",x),l(w,"dragstart",x),x},p.addMouseWheelListener=function(M,y,I){l(M,"wheel",function(w){var x=.15,N=w.deltaX||0,D=w.deltaY||0;switch(w.deltaMode){case w.DOM_DELTA_PIXEL:w.wheelX=N*x,w.wheelY=D*x;break;case w.DOM_DELTA_LINE:var R=15;w.wheelX=N*R,w.wheelY=D*R;break;case w.DOM_DELTA_PAGE:var S=150;w.wheelX=N*S,w.wheelY=D*S;break}y(w)},I)},p.addMultiMouseDownListener=function(M,y,I,w,x){var N=0,D,R,S,F={2:"dblclick",3:"tripleclick",4:"quadclick"};function A(E){if(p.getButton(E)!==0?N=0:E.detail>1?(N++,N>4&&(N=1)):N=1,P.isIE){var O=Math.abs(E.clientX-D)>5||Math.abs(E.clientY-R)>5;(!S||O)&&(N=1),S&&clearTimeout(S),S=setTimeout(function(){S=null},y[N-1]||600),N==1&&(D=E.clientX,R=E.clientY)}if(E._clicks=N,I[w]("mousedown",E),N>4)N=0;else if(N>1)return I[w](F[N],E)}Array.isArray(M)||(M=[M]),M.forEach(function(E){l(E,"mousedown",A,x)})};var d=function(M){return 0|(M.ctrlKey?1:0)|(M.altKey?2:0)|(M.shiftKey?4:0)|(M.metaKey?8:0)};p.getModifierString=function(M){return B.KEY_MODS[d(M)]};function g(M,y,I){var w=d(y);if(!P.isMac&&C){if(y.getModifierState&&(y.getModifierState("OS")||y.getModifierState("Win"))&&(w|=8),C.altGr)if((3&w)!=3)C.altGr=0;else return;if(I===18||I===17){var x="location"in y?y.location:y.keyLocation;if(I===17&&x===1)C[I]==1&&(f=y.timeStamp);else if(I===18&&w===3&&x===2){var N=y.timeStamp-f;N<50&&(C.altGr=!0)}}}if(I in B.MODIFIER_KEYS&&(I=-1),!w&&I===13){var x="location"in y?y.location:y.keyLocation;if(x===3&&(M(y,w,-I),y.defaultPrevented))return}if(P.isChromeOS&&w&8){if(M(y,w,I),y.defaultPrevented)return;w&=-9}return!w&&!(I in B.FUNCTION_KEYS)&&!(I in B.PRINTABLE_KEYS)?!1:M(y,w,I)}p.addCommandKeyListener=function(M,y,I){if(P.isOldGecko||P.isOpera&&!("KeyboardEvent"in window)){var w=null;l(M,"keydown",function(N){w=N.keyCode},I),l(M,"keypress",function(N){return g(y,N,w)},I)}else{var x=null;l(M,"keydown",function(N){C[N.keyCode]=(C[N.keyCode]||0)+1;var D=g(y,N,N.keyCode);return x=N.defaultPrevented,D},I),l(M,"keypress",function(N){x&&(N.ctrlKey||N.altKey||N.shiftKey||N.metaKey)&&(p.stopEvent(N),x=null)},I),l(M,"keyup",function(N){C[N.keyCode]=null},I),C||(_(),l(window,"focus",_))}};function _(){C=Object.create(null)}if(typeof window=="object"&&window.postMessage&&!P.isOldIE){var v=1;p.nextTick=function(M,y){y=y||window;var I="zero-timeout-message-"+v++,w=function(x){x.data==I&&(p.stopPropagation(x),h(y,"message",w),M())};l(y,"message",w),y.postMessage(I,"*")}}p.$idleBlocked=!1,p.onIdle=function(M,y){return setTimeout(function I(){p.$idleBlocked?setTimeout(I,100):M()},y)},p.$idleBlockId=null,p.blockIdle=function(M){p.$idleBlockId&&clearTimeout(p.$idleBlockId),p.$idleBlocked=!0,p.$idleBlockId=setTimeout(function(){p.$idleBlocked=!1},M||100)},p.nextFrame=typeof window=="object"&&(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame),p.nextFrame?p.nextFrame=p.nextFrame.bind(window):p.nextFrame=function(M){setTimeout(M,17)}}),ace.define("ace/clipboard",["require","exports","module"],function(s,p,m){var B;m.exports={lineMode:!1,pasteCancelled:function(){return B&&B>Date.now()-50?!0:B=!1},cancel:function(){B=Date.now()}}}),ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/config","ace/lib/useragent","ace/lib/dom","ace/lib/lang","ace/clipboard","ace/lib/keys"],function(s,p,m){var B=s("../lib/event"),P=s("../config").nls,C=s("../lib/useragent"),f=s("../lib/dom"),a=s("../lib/lang"),r=s("../clipboard"),o=C.isChrome<18,c=C.isIE,l=C.isChrome>63,h=400,d=s("../lib/keys"),g=d.KEY_MODS,_=C.isIOS,v=_?/\s/:/\n/,M=C.isMobile,y=function(I,w){var x=f.createElement("textarea");x.className="ace_text-input",x.setAttribute("wrap","off"),x.setAttribute("autocorrect","off"),x.setAttribute("autocapitalize","off"),x.setAttribute("spellcheck",!1),x.style.opacity="0",I.insertBefore(x,I.firstChild);var N=!1,D=!1,R=!1,S=!1,F="";M||(x.style.fontSize="1px");var A=!1,E=!1,O="",k=0,H=0,V=0;try{var W=document.activeElement===x}catch{}this.setAriaOptions=function(ae){ae.activeDescendant?(x.setAttribute("aria-haspopup","true"),x.setAttribute("aria-autocomplete",ae.inline?"both":"list"),x.setAttribute("aria-activedescendant",ae.activeDescendant)):(x.setAttribute("aria-haspopup","false"),x.setAttribute("aria-autocomplete","both"),x.removeAttribute("aria-activedescendant")),ae.role&&x.setAttribute("role",ae.role)},this.setAriaLabel=function(){if(w.session&&w.renderer.enableKeyboardAccessibility){var ae=w.session.selection.cursor.row;x.setAttribute("aria-roledescription",P("editor")),x.setAttribute("aria-label",P("Cursor at row $0",[ae+1]))}else x.removeAttribute("aria-roledescription"),x.removeAttribute("aria-label")},this.setAriaOptions({role:"textbox"}),this.setAriaLabel(),B.addListener(x,"blur",function(ae){E||(w.onBlur(ae),W=!1,M&&!_&&document.removeEventListener("selectionchange",J))},w),B.addListener(x,"focus",function(ae){if(!E){if(W=!0,C.isEdge)try{if(!document.hasFocus())return}catch{}w.onFocus(ae),C.isEdge?setTimeout(K):K(),M&&!_&&document.addEventListener("selectionchange",J)}},w),this.$focusScroll=!1,this.focus=function(){if(this.setAriaLabel(),F||l||this.$focusScroll=="browser")return x.focus({preventScroll:!0});var ae=x.style.top;x.style.position="fixed",x.style.top="0px";try{var ue=x.getBoundingClientRect().top!=0}catch{return}var be=[];if(ue)for(var Ne=x.parentElement;Ne&&Ne.nodeType==1;)be.push(Ne),Ne.setAttribute("ace_nocontext",!0),!Ne.parentElement&&Ne.getRootNode?Ne=Ne.getRootNode().host:Ne=Ne.parentElement;x.focus({preventScroll:!0}),ue&&be.forEach(function(Be){Be.removeAttribute("ace_nocontext")}),setTimeout(function(){x.style.position="",x.style.top=="0px"&&(x.style.top=ae)},0)},this.blur=function(){x.blur()},this.isFocused=function(){return W},w.on("beforeEndOperation",function(){var ae=w.curOp,ue=ae&&ae.command&&ae.command.name;if(ue!="insertstring"){var be=ue&&(ae.docChanged||ae.selectionChanged);R&&be&&(O=x.value="",Ue()),K()}});var K=_?function(ae){if(!(!W||N&&!ae||S)){ae||(ae="");var ue=` ab`+ae+`cde fg -`;ue!=x.value&&(x.value=L=ue);var be=4,Ne=4+(ae.length||(b.selection.isEmpty()?0:1));(O!=be||H!=Ne)&&x.setSelectionRange(be,Ne),O=be,H=Ne}}:function(){if(!(R||w)&&!(!W&&!z)){R=!0;var ae=0,ue=0,be="";if(b.session){var Ne=b.selection,Be=Ne.getRange(),He=Ne.cursor.row;if(ae=Be.start.column,ue=Be.end.column,be=b.session.getLine(He),Be.start.row!=He){var Qe=b.session.getLine(He-1);ae=Be.start.rowHe+1?Ve.length:ue,ue+=be.length+1,be=be+` -`+Ve}else k&&He>0&&(be=` +`;ue!=x.value&&(x.value=O=ue);var be=4,Ne=4+(ae.length||(w.selection.isEmpty()?0:1));(k!=be||H!=Ne)&&x.setSelectionRange(be,Ne),k=be,H=Ne}}:function(){if(!(R||S)&&!(!W&&!z)){R=!0;var ae=0,ue=0,be="";if(w.session){var Ne=w.selection,Be=Ne.getRange(),Ve=Ne.cursor.row;if(ae=Be.start.column,ue=Be.end.column,be=w.session.getLine(Ve),Be.start.row!=Ve){var Qe=w.session.getLine(Ve-1);ae=Be.start.rowVe+1?We.length:ue,ue+=be.length+1,be=be+` +`+We}else M&&Ve>0&&(be=` `+be,ue+=1,ae+=1);be.length>h&&(ae=L.length&&ae.value===L&&L&&ae.selectionEnd!==H},ie=function(ae){R||(N?N=!1:Q(x)?(b.selectAll(),K()):k&&x.selectionStart!=O&&K())};function J(ae){if((!x||!x.parentNode)&&document.removeEventListener("selectionchange",J),!R&&x.selectionStart===x.selectionEnd){var ue=x.selectionStart-O,be=H-O;ue>0?ue=Math.max(ue-be,1):ue===0&&be&&(ue=-1);for(var Ne=Math.abs(ue),Be=ue>0?d.right:d.left,He=0;He0&&L[U]==ae[U];)U++,Be--;for(Qe=Qe.slice(U),U=1;He>0&&L.length-U>O-1&&L[L.length-U]==ae[ae.length-U];)U++,He--;Ve-=U-1,M-=U-1;var j=Qe.length-U+1;if(j<0&&(Be=-j,j=0),Qe=Qe.slice(0,j),!ue&&!Qe&&!Ve&&!Be&&!He&&!M)return"";w=!0;var ne=!1;return C.isAndroid&&Qe==". "&&(Qe=" ",ne=!0),Qe&&!Be&&!He&&!Ve&&!M||A?b.onTextInput(Qe):b.onTextInput(Qe,{extendLeft:Be,extendRight:He,restoreStart:Ve,restoreEnd:M}),w=!1,L=ae,O=be,H=Ne,V=M,ne?` -`:Qe},he=function(ae){if(R)return nt();if(ae&&ae.inputType){if(ae.inputType=="historyUndo")return b.execCommand("undo");if(ae.inputType=="historyRedo")return b.execCommand("redo")}var ue=x.value,be=oe(ue,!0);(ue.length>h+100||v.test(be)||k&&O<1&&O==H)&&K()},de=function(ae,ue,be){var Ne=ae.clipboardData||window.clipboardData;if(!(!Ne||o)){var Be=c||be?"Text":"text/plain";try{return ue?Ne.setData(Be,ue)!==!1:Ne.getData(Be)}catch(He){if(!be)return de(He,ue,!0)}}},fe=function(ae,ue){var be=b.getCopyText();if(!be)return B.preventDefault(ae);de(ae,be)?(_&&(K(be),N=be,setTimeout(function(){N=!1},10)),ue?b.onCut():b.onCopy(),B.preventDefault(ae)):(N=!0,x.value=be,x.select(),setTimeout(function(){N=!1,K(),ue?b.onCut():b.onCopy()}))},le=function(ae){fe(ae,!0)},Re=function(ae){fe(ae,!1)},Ke=function(ae){var ue=de(ae);s.pasteCancelled()||(typeof ue=="string"?(ue&&b.onPaste(ue,ae),C.isIE&&setTimeout(K),B.preventDefault(ae)):(x.value="",D=!0))};B.addCommandKeyListener(x,b.onCommandKey.bind(b),b),B.addListener(x,"select",ie,b),B.addListener(x,"input",he,b),B.addListener(x,"cut",le,b),B.addListener(x,"copy",Re,b),B.addListener(x,"paste",Ke,b),(!("oncut"in x)||!("oncopy"in x)||!("onpaste"in x))&&B.addListener(S,"keydown",function(ae){if(!(C.isMac&&!ae.metaKey||!ae.ctrlKey))switch(ae.keyCode){case 67:Re(ae);break;case 86:Ke(ae);break;case 88:le(ae);break}},b);var vt=function(ae){if(!(R||!b.onCompositionStart||b.$readOnly)&&(R={},!A)){ae.data&&(R.useTextareaForIME=!1),setTimeout(nt,0),b._signal("compositionStart"),b.on("mousedown",De);var ue=b.getSelectionRange();ue.end.row=ue.start.row,ue.end.column=ue.start.column,R.markerRange=ue,R.selectionStart=O,b.onCompositionStart(R),R.useTextareaForIME?(L=x.value="",O=0,H=0):(x.msGetInputContext&&(R.context=x.msGetInputContext()),x.getInputContext&&(R.context=x.getInputContext()))}},nt=function(){if(!(!R||!b.onCompositionUpdate||b.$readOnly)){if(A)return De();if(R.useTextareaForIME)b.onCompositionUpdate(x.value);else{var ae=x.value;oe(ae),R.markerRange&&(R.context&&(R.markerRange.start.column=R.selectionStart=R.context.compositionStartOffset),R.markerRange.end.column=R.markerRange.start.column+H-R.selectionStart+V)}}},Ue=function(ae){!b.onCompositionEnd||b.$readOnly||(R=!1,b.onCompositionEnd(),b.off("mousedown",De),ae&&he())};function De(){T=!0,x.blur(),x.focus(),T=!1}var Pt=a.delayedCall(nt,50).schedule.bind(null,null);function Ct(ae){ae.keyCode==27&&x.value.lengthH&&L[M]==` -`?U=d.end:VeH&&L.slice(0,M).split(` -`).length>2?U=d.down:M>H&&L[M-1]==" "?(U=d.right,j=g.option):(M>H||M==H&&H!=O&&Ve==M)&&(U=d.right),Ve!==M&&(j|=g.shift),U){var ne=ue.onCommandKey({},j,U);if(!ne&&ue.commands){U=d.keyCodeToString(U);var se=ue.commands.findKeyCommand(j,U);se&&ue.execCommand(se)}O=Ve,H=M,K("")}}};document.addEventListener("selectionchange",He),ue.on("destroy",function(){document.removeEventListener("selectionchange",He)})}this.destroy=function(){x.parentElement&&x.parentElement.removeChild(x)}};p.TextInput=I,p.$setUserAgentForTests=function(S,b){k=S,_=b}}),ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/useragent"],function(r,p,m){var B=r("../lib/useragent"),P=0,C=550,f=function(){function o(c){c.$clickSelection=null;var l=c.editor;l.setDefaultHandler("mousedown",this.onMouseDown.bind(c)),l.setDefaultHandler("dblclick",this.onDoubleClick.bind(c)),l.setDefaultHandler("tripleclick",this.onTripleClick.bind(c)),l.setDefaultHandler("quadclick",this.onQuadClick.bind(c)),l.setDefaultHandler("mousewheel",this.onMouseWheel.bind(c));var h=["select","startSelect","selectEnd","selectAllEnd","selectByWordsEnd","selectByLinesEnd","dragWait","dragWaitEnd","focusWait"];h.forEach(function(d){c[d]=this[d]},this),c.selectByLines=this.extendSelectionBy.bind(c,"getLineRange"),c.selectByWords=this.extendSelectionBy.bind(c,"getWordRange")}return o.prototype.onMouseDown=function(c){var l=c.inSelection(),h=c.getDocumentPosition();this.mousedownEvent=c;var d=this.editor,g=c.getButton();if(g!==0){var _=d.getSelectionRange(),v=_.isEmpty();(v||g==1)&&d.selection.moveToPosition(h),g==2&&(d.textInput.onContextMenu(c.domEvent),B.isMozilla||c.preventDefault());return}if(this.mousedownEvent.time=Date.now(),l&&!d.isFocused()&&(d.focus(),this.$focusTimeout&&!this.$clickSelection&&!d.inMultiSelectMode)){this.setState("focusWait"),this.captureMouse(c);return}return this.captureMouse(c),this.startSelect(h,c.domEvent._clicks>1),c.preventDefault()},o.prototype.startSelect=function(c,l){c=c||this.editor.renderer.screenToTextCoordinates(this.x,this.y);var h=this.editor;this.mousedownEvent&&(this.mousedownEvent.getShiftKey()?h.selection.selectToPosition(c):l||h.selection.moveToPosition(c),l||this.select(),h.setStyle("ace_selecting"),this.setState("select"))},o.prototype.select=function(){var c,l=this.editor,h=l.renderer.screenToTextCoordinates(this.x,this.y);if(this.$clickSelection){var d=this.$clickSelection.comparePoint(h);if(d==-1)c=this.$clickSelection.end;else if(d==1)c=this.$clickSelection.start;else{var g=s(this.$clickSelection,h);h=g.cursor,c=g.anchor}l.selection.setSelectionAnchor(c.row,c.column)}l.selection.selectToPosition(h),l.renderer.scrollCursorIntoView()},o.prototype.extendSelectionBy=function(c){var l,h=this.editor,d=h.renderer.screenToTextCoordinates(this.x,this.y),g=h.selection[c](d.row,d.column);if(this.$clickSelection){var _=this.$clickSelection.comparePoint(g.start),v=this.$clickSelection.comparePoint(g.end);if(_==-1&&v<=0)l=this.$clickSelection.end,(g.end.row!=d.row||g.end.column!=d.column)&&(d=g.start);else if(v==1&&_>=0)l=this.$clickSelection.start,(g.start.row!=d.row||g.start.column!=d.column)&&(d=g.end);else if(_==-1&&v==1)d=g.end,l=g.start;else{var k=s(this.$clickSelection,d);d=k.cursor,l=k.anchor}h.selection.setSelectionAnchor(l.row,l.column)}h.selection.selectToPosition(d),h.renderer.scrollCursorIntoView()},o.prototype.selectByLinesEnd=function(){this.$clickSelection=null,this.editor.unsetStyle("ace_selecting")},o.prototype.focusWait=function(){var c=a(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y),l=Date.now();(c>P||l-this.mousedownEvent.time>this.$focusTimeout)&&this.startSelect(this.mousedownEvent.getDocumentPosition())},o.prototype.onDoubleClick=function(c){var l=c.getDocumentPosition(),h=this.editor,d=h.session,g=d.getBracketRange(l);g?(g.isEmpty()&&(g.start.column--,g.end.column++),this.setState("select")):(g=h.selection.getWordRange(l.row,l.column),this.setState("selectByWords")),this.$clickSelection=g,this.select()},o.prototype.onTripleClick=function(c){var l=c.getDocumentPosition(),h=this.editor;this.setState("selectByLines");var d=h.getSelectionRange();d.isMultiLine()&&d.contains(l.row,l.column)?(this.$clickSelection=h.selection.getLineRange(d.start.row),this.$clickSelection.end=h.selection.getLineRange(d.end.row).end):this.$clickSelection=h.selection.getLineRange(l.row),this.select()},o.prototype.onQuadClick=function(c){var l=this.editor;l.selectAll(),this.$clickSelection=l.getSelectionRange(),this.setState("selectAll")},o.prototype.onMouseWheel=function(c){if(!c.getAccelKey()){c.getShiftKey()&&c.wheelY&&!c.wheelX&&(c.wheelX=c.wheelY,c.wheelY=0);var l=this.editor;this.$lastScroll||(this.$lastScroll={t:0,vx:0,vy:0,allowed:0});var h=this.$lastScroll,d=c.domEvent.timeStamp,g=d-h.t,_=g?c.wheelX/g:h.vx,v=g?c.wheelY/g:h.vy;g=1&&l.renderer.isScrollableBy(c.wheelX*c.speed,0)&&(I=!0),k<=1&&l.renderer.isScrollableBy(0,c.wheelY*c.speed)&&(I=!0),I)h.allowed=d;else if(d-h.allowed=h.length&&(h=void 0),{value:h&&h[_++],done:!h}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")},C=r("./lib/dom"),f=r("./range").Range,a="ace_tooltip",s=function(){function h(d){this.isOpen=!1,this.$element=null,this.$parentNode=d}return h.prototype.$init=function(){return this.$element=C.createElement("div"),this.$element.className=a,this.$element.style.display="none",this.$parentNode.appendChild(this.$element),this.$element},h.prototype.getElement=function(){return this.$element||this.$init()},h.prototype.setText=function(d){this.getElement().textContent=d},h.prototype.setHtml=function(d){this.getElement().innerHTML=d},h.prototype.setPosition=function(d,g){this.getElement().style.left=d+"px",this.getElement().style.top=g+"px"},h.prototype.setClassName=function(d){C.addCssClass(this.getElement(),d)},h.prototype.setTheme=function(d){this.$element.className=a+" "+(d.isDark?"ace_dark ":"")+(d.cssClass||"")},h.prototype.show=function(d,g,_){d!=null&&this.setText(d),g!=null&&_!=null&&this.setPosition(g,_),this.isOpen||(this.getElement().style.display="block",this.isOpen=!0)},h.prototype.hide=function(){this.isOpen&&(this.getElement().style.display="none",this.getElement().className=a,this.isOpen=!1)},h.prototype.getHeight=function(){return this.getElement().offsetHeight},h.prototype.getWidth=function(){return this.getElement().offsetWidth},h.prototype.destroy=function(){this.isOpen=!1,this.$element&&this.$element.parentNode&&this.$element.parentNode.removeChild(this.$element)},h}(),o=function(){function h(){this.popups=[]}return h.prototype.addPopup=function(d){this.popups.push(d),this.updatePopups()},h.prototype.removePopup=function(d){var g=this.popups.indexOf(d);g!==-1&&(this.popups.splice(g,1),this.updatePopups())},h.prototype.updatePopups=function(){var d,g,_,v;this.popups.sort(function(w,F){return F.priority-w.priority});var k=[];try{for(var I=P(this.popups),S=I.next();!S.done;S=I.next()){var b=S.value,x=!0;try{for(var N=(_=void 0,P(k)),D=N.next();!D.done;D=N.next()){var R=D.value;if(this.doPopupsOverlap(R,b)){x=!1;break}}}catch(w){_={error:w}}finally{try{D&&!D.done&&(v=N.return)&&v.call(N)}finally{if(_)throw _.error}}x?k.push(b):b.hide()}}catch(w){d={error:w}}finally{try{S&&!S.done&&(g=I.return)&&g.call(I)}finally{if(d)throw d.error}}},h.prototype.doPopupsOverlap=function(d,g){var _=d.getElement().getBoundingClientRect(),v=g.getElement().getBoundingClientRect();return _.leftv.left&&_.topv.top},h}(),c=new o;p.popupManager=c,p.Tooltip=s;var l=function(h){B(d,h);function d(g){g===void 0&&(g=document.body);var _=h.call(this,g)||this;_.timeout=void 0,_.lastT=0,_.idleTime=350,_.lastEvent=void 0,_.onMouseOut=_.onMouseOut.bind(_),_.onMouseMove=_.onMouseMove.bind(_),_.waitForHover=_.waitForHover.bind(_),_.hide=_.hide.bind(_);var v=_.getElement();return v.style.whiteSpace="pre-wrap",v.style.pointerEvents="auto",v.addEventListener("mouseout",_.onMouseOut),v.tabIndex=-1,v.addEventListener("blur",function(){v.contains(document.activeElement)||this.hide()}.bind(_)),_}return d.prototype.addToEditor=function(g){g.on("mousemove",this.onMouseMove),g.on("mousedown",this.hide),g.renderer.getMouseEventTarget().addEventListener("mouseout",this.onMouseOut,!0)},d.prototype.removeFromEditor=function(g){g.off("mousemove",this.onMouseMove),g.off("mousedown",this.hide),g.renderer.getMouseEventTarget().removeEventListener("mouseout",this.onMouseOut,!0),this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},d.prototype.onMouseMove=function(g,_){this.lastEvent=g,this.lastT=Date.now();var v=_.$mouseHandler.isMousePressed;if(this.isOpen){var k=this.lastEvent&&this.lastEvent.getDocumentPosition();(!this.range||!this.range.contains(k.row,k.column)||v||this.isOutsideOfText(this.lastEvent))&&this.hide()}this.timeout||v||(this.lastEvent=g,this.timeout=setTimeout(this.waitForHover,this.idleTime))},d.prototype.waitForHover=function(){this.timeout&&clearTimeout(this.timeout);var g=Date.now()-this.lastT;if(this.idleTime-g>10){this.timeout=setTimeout(this.waitForHover,this.idleTime-g);return}this.timeout=null,this.lastEvent&&!this.isOutsideOfText(this.lastEvent)&&this.$gatherData(this.lastEvent,this.lastEvent.editor)},d.prototype.isOutsideOfText=function(g){var _=g.editor,v=g.getDocumentPosition(),k=_.session.getLine(v.row);if(v.column==k.length){var I=_.renderer.pixelToScreenCoordinates(g.clientX,g.clientY),S=_.session.documentToScreenPosition(v.row,v.column);if(S.column!=I.column||S.row!=I.row)return!0}return!1},d.prototype.setDataProvider=function(g){this.$gatherData=g},d.prototype.showForRange=function(g,_,v,k){if(!(k&&k!=this.lastEvent)&&!(this.isOpen&&document.activeElement==this.getElement())){var I=g.renderer;this.isOpen||(c.addPopup(this),this.$registerCloseEvents(),this.setTheme(I.theme)),this.isOpen=!0,this.addMarker(_,g.session),this.range=f.fromPoints(_.start,_.end);var S=this.getElement();S.innerHTML="",S.appendChild(v),S.style.display="block";var b=I.textToScreenCoordinates(_.start.row,_.start.column),x=g.getCursorPosition(),N=S.clientHeight,D=I.scroller.getBoundingClientRect(),R=!0;this.row>x.row?R=!0:this.rowD.bottom&&(R=!1),R?b.pageY+=I.lineHeight:b.pageY-=N,S.style.maxWidth=D.width-(b.pageX-D.left)+"px",this.setPosition(b.pageX,b.pageY)}},d.prototype.addMarker=function(g,_){this.marker&&this.$markerSession.removeMarker(this.marker),this.$markerSession=_,this.marker=_&&_.addMarker(g,"ace_highlight-marker","text")},d.prototype.hide=function(g){!g&&document.activeElement==this.getElement()||g&&g.target&&(g.type!="keydown"||g.ctrlKey||g.metaKey)&&this.$element.contains(g.target)||(this.lastEvent=null,this.timeout&&clearTimeout(this.timeout),this.timeout=null,this.addMarker(null),this.isOpen&&(this.$removeCloseEvents(),this.getElement().style.display="none",this.isOpen=!1,c.removePopup(this)))},d.prototype.$registerCloseEvents=function(){window.addEventListener("keydown",this.hide,!0),window.addEventListener("mousewheel",this.hide,!0),window.addEventListener("mousedown",this.hide,!0)},d.prototype.$removeCloseEvents=function(){window.removeEventListener("keydown",this.hide,!0),window.removeEventListener("mousewheel",this.hide,!0),window.removeEventListener("mousedown",this.hide,!0)},d.prototype.onMouseOut=function(g){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.lastEvent=null,this.isOpen&&(!g.relatedTarget||g.relatedTarget==this.getElement()||g&&g.currentTarget.contains(g.relatedTarget)||g.relatedTarget.classList.contains("ace_content")||this.hide())},d}(s);p.HoverTooltip=l}),ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/tooltip","ace/config"],function(r,p,m){var B=this&&this.__extends||function(){var l=function(h,d){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,_){g.__proto__=_}||function(g,_){for(var v in _)Object.prototype.hasOwnProperty.call(_,v)&&(g[v]=_[v])},l(h,d)};return function(h,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");l(h,d);function g(){this.constructor=h}h.prototype=d===null?Object.create(d):(g.prototype=d.prototype,new g)}}(),P=this&&this.__values||function(l){var h=typeof Symbol=="function"&&Symbol.iterator,d=h&&l[h],g=0;if(d)return d.call(l);if(l&&typeof l.length=="number")return{next:function(){return l&&g>=l.length&&(l=void 0),{value:l&&l[g++],done:!l}}};throw new TypeError(h?"Object is not iterable.":"Symbol.iterator is not defined.")},C=r("../lib/dom"),f=r("../lib/event"),a=r("../tooltip").Tooltip,s=r("../config").nls;function o(l){var h=l.editor,d=h.renderer.$gutterLayer,g=new c(h);l.editor.setDefaultHandler("guttermousedown",function(b){if(!(!h.isFocused()||b.getButton()!=0)){var x=d.getRegion(b);if(x!="foldWidgets"){var N=b.getDocumentPosition().row,D=h.session.selection;if(b.getShiftKey())D.selectTo(N,0);else{if(b.domEvent.detail==2)return h.selectAll(),b.preventDefault();l.$clickSelection=h.selection.getLineRange(N)}return l.setState("selectByLines"),l.captureMouse(b),b.preventDefault()}}});var _,v;function k(){var b=v.getDocumentPosition().row,x=h.session.getLength();if(b==x){var N=h.renderer.pixelToScreenCoordinates(0,v.y).row,D=v.$pos;if(N>h.session.documentToScreenRow(D.row,D.column))return I()}if(g.showTooltip(b),!!g.isOpen)if(h.on("mousewheel",I),l.$tooltipFollowsMouse)S(v);else{var R=d.$lines.cells[b].element.querySelector("[class*=ace_icon]"),w=R.getBoundingClientRect(),F=g.getElement().style;F.left=w.right+"px",F.top=w.bottom+"px"}}function I(){_&&(_=clearTimeout(_)),g.isOpen&&(g.hide(),h._signal("hideGutterTooltip",g),h.off("mousewheel",I))}function S(b){g.setPosition(b.x,b.y)}l.editor.setDefaultHandler("guttermousemove",function(b){var x=b.domEvent.target||b.domEvent.srcElement;if(C.hasCssClass(x,"ace_fold-widget"))return I();g.isOpen&&l.$tooltipFollowsMouse&&S(b),v=b,!_&&(_=setTimeout(function(){_=null,v&&!l.isMousePressed?k():I()},50))}),f.addListener(h.renderer.$gutter,"mouseout",function(b){v=null,!(!g.isOpen||_)&&(_=setTimeout(function(){_=null,I()},50))},h),h.on("changeSession",I),h.on("input",I)}p.GutterHandler=o;var c=function(l){B(h,l);function h(d){var g=l.call(this,d.container)||this;return g.editor=d,g}return h.prototype.setPosition=function(d,g){var _=window.innerWidth||document.documentElement.clientWidth,v=window.innerHeight||document.documentElement.clientHeight,k=this.getWidth(),I=this.getHeight();d+=15,g+=15,d+k>_&&(d-=d+k-_),g+I>v&&(g-=20+I),a.prototype.setPosition.call(this,d,g)},Object.defineProperty(h,"annotationLabels",{get:function(){return{error:{singular:s("error"),plural:s("errors")},warning:{singular:s("warning"),plural:s("warnings")},info:{singular:s("information message"),plural:s("information messages")}}},enumerable:!1,configurable:!0}),h.prototype.showTooltip=function(d){var g=this.editor.renderer.$gutterLayer,_=g.$annotations[d],v;_?v={text:Array.from(_.text),type:Array.from(_.type)}:v={text:[],type:[]};var k=g.session.getFoldLine(d);if(k&&g.$showFoldedAnnotations){for(var I={error:[],warning:[],info:[]},S,b=d+1;b<=k.end.row;b++)if(g.$annotations[b])for(var x=0;x ").concat(v.text[b]);R[v.type[b].replace("_fold","")].push(F)}var A=[].concat(R.error,R.warning,R.info).join("
");this.setHtml(A),this.setClassName("ace_gutter-tooltip"),this.$element.setAttribute("aria-live","polite"),this.isOpen||this.setTheme(this.editor.renderer.theme),this.editor._signal("showGutterTooltip",this),this.show()},h.annotationsToSummaryString=function(d){var g,_,v=[],k=["error","warning","info"];try{for(var I=P(k),S=I.next();!S.done;S=I.next()){var b=S.value;if(d[b].length){var x=d[b].length===1?h.annotationLabels[b].singular:h.annotationLabels[b].plural;v.push("".concat(d[b].length," ").concat(x))}}}catch(N){g={error:N}}finally{try{S&&!S.done&&(_=I.return)&&_.call(I)}finally{if(g)throw g.error}}return v.join(", ")},h}(a);p.GutterTooltip=c}),ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"],function(r,p,m){var B=r("../lib/event"),P=r("../lib/useragent"),C=function(){function f(a,s){this.domEvent=a,this.editor=s,this.x=this.clientX=a.clientX,this.y=this.clientY=a.clientY,this.$pos=null,this.$inSelection=null,this.propagationStopped=!1,this.defaultPrevented=!1}return f.prototype.stopPropagation=function(){B.stopPropagation(this.domEvent),this.propagationStopped=!0},f.prototype.preventDefault=function(){B.preventDefault(this.domEvent),this.defaultPrevented=!0},f.prototype.stop=function(){this.stopPropagation(),this.preventDefault()},f.prototype.getDocumentPosition=function(){return this.$pos?this.$pos:(this.$pos=this.editor.renderer.screenToTextCoordinates(this.clientX,this.clientY),this.$pos)},f.prototype.inSelection=function(){if(this.$inSelection!==null)return this.$inSelection;var a=this.editor,s=a.getSelectionRange();if(s.isEmpty())this.$inSelection=!1;else{var o=this.getDocumentPosition();this.$inSelection=s.contains(o.row,o.column)}return this.$inSelection},f.prototype.getButton=function(){return B.getButton(this.domEvent)},f.prototype.getShiftKey=function(){return this.domEvent.shiftKey},f.prototype.getAccelKey=function(){return P.isMac?this.domEvent.metaKey:this.domEvent.ctrlKey},f}();p.MouseEvent=C}),ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"],function(r,p,m){var B=r("../lib/dom"),P=r("../lib/event"),C=r("../lib/useragent"),f=200,a=200,s=5;function o(l){var h=l.editor,d=B.createElement("div");d.style.cssText="top:-100px;position:absolute;z-index:2147483647;opacity:0.5",d.textContent=" ";var g=["dragWait","dragWaitEnd","startDrag","dragReadyEnd","onMouseDrag"];g.forEach(function(J){l[J]=this[J]},this),h.on("mousedown",this.onMouseDown.bind(l));var _=h.container,v,k,I,S,b,x,N=0,D,R,w,F,A;this.onDragStart=function(J){if(this.cancelDrag||!_.draggable){var Y=this;return setTimeout(function(){Y.startSelect(),Y.captureMouse(J)},0),J.preventDefault()}b=h.getSelectionRange();var z=J.dataTransfer;z.effectAllowed=h.getReadOnly()?"copy":"copyMove",h.container.appendChild(d),z.setDragImage&&z.setDragImage(d,0,0),setTimeout(function(){h.container.removeChild(d)}),z.clearData(),z.setData("Text",h.session.getTextRange()),R=!0,this.setState("drag")},this.onDragEnd=function(J){if(_.draggable=!1,R=!1,this.setState(null),!h.getReadOnly()){var Y=J.dataTransfer.dropEffect;!D&&Y=="move"&&h.session.remove(h.getSelectionRange()),h.$resetCursorStyle()}this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle("")},this.onDragEnter=function(J){if(!(h.getReadOnly()||!Q(J.dataTransfer)))return k=J.clientX,I=J.clientY,v||H(),N++,J.dataTransfer.dropEffect=D=ie(J),P.preventDefault(J)},this.onDragOver=function(J){if(!(h.getReadOnly()||!Q(J.dataTransfer)))return k=J.clientX,I=J.clientY,v||(H(),N++),W!==null&&(W=null),J.dataTransfer.dropEffect=D=ie(J),P.preventDefault(J)},this.onDragLeave=function(J){if(N--,N<=0&&v)return V(),D=null,P.preventDefault(J)},this.onDrop=function(J){if(x){var Y=J.dataTransfer;if(R)switch(D){case"move":b.contains(x.row,x.column)?b={start:x,end:x}:b=h.moveText(b,x);break;case"copy":b=h.moveText(b,x,!0);break}else{var z=Y.getData("Text");b={start:x,end:h.session.insert(x,z)},h.focus(),D=null}return V(),P.preventDefault(J)}},P.addListener(_,"dragstart",this.onDragStart.bind(l),h),P.addListener(_,"dragend",this.onDragEnd.bind(l),h),P.addListener(_,"dragenter",this.onDragEnter.bind(l),h),P.addListener(_,"dragover",this.onDragOver.bind(l),h),P.addListener(_,"dragleave",this.onDragLeave.bind(l),h),P.addListener(_,"drop",this.onDrop.bind(l),h);function T(J,Y){var z=Date.now(),oe=!Y||J.row!=Y.row,he=!Y||J.column!=Y.column;if(!F||oe||he)h.moveCursorToPosition(J),F=z,A={x:k,y:I};else{var de=c(A.x,A.y,k,I);de>s?F=null:z-F>=a&&(h.renderer.scrollCursorIntoView(),F=null)}}function L(J,Y){var z=Date.now(),oe=h.renderer.layerConfig.lineHeight,he=h.renderer.layerConfig.characterWidth,de=h.renderer.scroller.getBoundingClientRect(),fe={x:{left:k-de.left,right:de.right-k},y:{top:I-de.top,bottom:de.bottom-I}},le=Math.min(fe.x.left,fe.x.right),Re=Math.min(fe.y.top,fe.y.bottom),Ke={row:J.row,column:J.column};le/he<=2&&(Ke.column+=fe.x.left=f&&h.renderer.scrollCursorIntoView(Ke):w=z:w=null}function O(){var J=x;x=h.renderer.screenToTextCoordinates(k,I),T(x,J),L(x,J)}function H(){b=h.selection.toOrientedRange(),v=h.session.addMarker(b,"ace_selection",h.getSelectionStyle()),h.clearSelection(),h.isFocused()&&h.renderer.$cursorLayer.setBlinking(!1),clearInterval(S),O(),S=setInterval(O,20),N=0,P.addListener(document,"mousemove",K)}function V(){clearInterval(S),h.session.removeMarker(v),v=null,h.selection.fromOrientedRange(b),h.isFocused()&&!R&&h.$resetCursorStyle(),b=null,x=null,N=0,w=null,F=null,P.removeListener(document,"mousemove",K)}var W=null;function K(){W==null&&(W=setTimeout(function(){W!=null&&v&&V()},20))}function Q(J){var Y=J.types;return!Y||Array.prototype.some.call(Y,function(z){return z=="text/plain"||z=="Text"})}function ie(J){var Y=["copy","copymove","all","uninitialized"],z=["move","copymove","linkmove","all","uninitialized"],oe=C.isMac?J.altKey:J.ctrlKey,he="uninitialized";try{he=J.dataTransfer.effectAllowed.toLowerCase()}catch{}var de="none";return oe&&Y.indexOf(he)>=0?de="copy":z.indexOf(he)>=0?de="move":Y.indexOf(he)>=0&&(de="copy"),de}}(function(){this.dragWait=function(){var l=Date.now()-this.mousedownEvent.time;l>this.editor.getDragDelay()&&this.startDrag()},this.dragWaitEnd=function(){var l=this.editor.container;l.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()),this.selectEnd()},this.dragReadyEnd=function(l){this.editor.$resetCursorStyle(),this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle(""),this.dragWaitEnd()},this.startDrag=function(){this.cancelDrag=!1;var l=this.editor,h=l.container;h.draggable=!0,l.renderer.$cursorLayer.setBlinking(!1),l.setStyle("ace_dragging");var d=C.isWin?"default":"move";l.renderer.setCursorStyle(d),this.setState("dragReady")},this.onMouseDrag=function(l){var h=this.editor.container;if(C.isIE&&this.state=="dragReady"){var d=c(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);d>3&&h.dragDrop()}if(this.state==="dragWait"){var d=c(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);d>0&&(h.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()))}},this.onMouseDown=function(l){if(this.$dragEnabled){this.mousedownEvent=l;var h=this.editor,d=l.inSelection(),g=l.getButton(),_=l.domEvent.detail||1;if(_===1&&g===0&&d){if(l.editor.inMultiSelectMode&&(l.getAccelKey()||l.getShiftKey()))return;this.mousedownEvent.time=Date.now();var v=l.domEvent.target||l.domEvent.srcElement;if("unselectable"in v&&(v.unselectable="on"),h.getDragDelay()){if(C.isWebKit){this.cancelDrag=!0;var k=h.container;k.draggable=!0}this.setState("dragWait")}else this.startDrag();this.captureMouse(l,this.onMouseDrag.bind(this)),l.defaultPrevented=!0}}}}).call(o.prototype);function c(l,h,d,g){return Math.sqrt(Math.pow(d-l,2)+Math.pow(g-h,2))}p.DragdropHandler=o}),ace.define("ace/mouse/touch_handler",["require","exports","module","ace/mouse/mouse_event","ace/lib/event","ace/lib/dom"],function(r,p,m){var B=r("./mouse_event").MouseEvent,P=r("../lib/event"),C=r("../lib/dom");p.addTouchListeners=function(f,a){var s="scroll",o,c,l,h,d,g,_=0,v,k=0,I=0,S=0,b,x;function N(){var T=window.navigator&&window.navigator.clipboard,L=!1,O=function(){var V=a.getCopyText(),W=a.session.getUndoManager().hasUndo();x.replaceChild(C.buildDom(L?["span",!V&&["span",{class:"ace_mobile-button",action:"selectall"},"Select All"],V&&["span",{class:"ace_mobile-button",action:"copy"},"Copy"],V&&["span",{class:"ace_mobile-button",action:"cut"},"Cut"],T&&["span",{class:"ace_mobile-button",action:"paste"},"Paste"],W&&["span",{class:"ace_mobile-button",action:"undo"},"Undo"],["span",{class:"ace_mobile-button",action:"find"},"Find"],["span",{class:"ace_mobile-button",action:"openCommandPallete"},"Palette"]]:["span"]),x.firstChild)},H=function(V){var W=V.target.getAttribute("action");if(W=="more"||!L)return L=!L,O();W=="paste"?T.readText().then(function(K){a.execCommand(W,K)}):W&&((W=="cut"||W=="copy")&&(T?T.writeText(a.getCopyText()):document.execCommand("copy")),a.execCommand(W)),x.firstChild.style.display="none",L=!1,W!="openCommandPallete"&&a.focus()};x=C.buildDom(["div",{class:"ace_mobile-menu",ontouchstart:function(V){s="menu",V.stopPropagation(),V.preventDefault(),a.textInput.focus()},ontouchend:function(V){V.stopPropagation(),V.preventDefault(),H(V)},onclick:H},["span"],["span",{class:"ace_mobile-button",action:"more"},"..."]],a.container)}function D(){x||N();var T=a.selection.cursor,L=a.renderer.textToScreenCoordinates(T.row,T.column),O=a.renderer.textToScreenCoordinates(0,0).pageX,H=a.renderer.scrollLeft,V=a.container.getBoundingClientRect();x.style.top=L.pageY-V.top-3+"px",L.pageX-V.left=2?a.selection.getLineRange(v.row):a.session.getBracketRange(v);T&&!T.isEmpty()?a.selection.setRange(T):a.selection.selectWord(),s="wait"}P.addListener(f,"contextmenu",function(T){if(b){var L=a.textInput.getElement();L.focus()}},a),P.addListener(f,"touchstart",function(T){var L=T.touches;if(d||L.length>1){clearTimeout(d),d=null,l=-1,s="zoom";return}b=a.$mouseHandler.isMousePressed=!0;var O=a.renderer.layerConfig.lineHeight,H=a.renderer.layerConfig.lineHeight,V=T.timeStamp;h=V;var W=L[0],K=W.clientX,Q=W.clientY;Math.abs(o-K)+Math.abs(c-Q)>O&&(l=-1),o=T.clientX=K,c=T.clientY=Q,I=S=0;var ie=new B(T,a);if(v=ie.getDocumentPosition(),V-l<500&&L.length==1&&!_)k++,T.preventDefault(),T.button=0,F();else{k=0;var J=a.selection.cursor,Y=a.selection.isEmpty()?J:a.selection.anchor,z=a.renderer.$cursorLayer.getPixelPosition(J,!0),oe=a.renderer.$cursorLayer.getPixelPosition(Y,!0),he=a.renderer.scroller.getBoundingClientRect(),de=a.renderer.layerConfig.offset,fe=a.renderer.scrollLeft,le=function(vt,nt){return vt=vt/H,nt=nt/O-.75,vt*vt+nt*nt};if(T.clientXKe?"cursor":"anchor"),Ke<3.5?s="anchor":Re<3.5?s="cursor":s="scroll",d=setTimeout(w,450)}l=V},a),P.addListener(f,"touchend",function(T){b=a.$mouseHandler.isMousePressed=!1,g&&clearInterval(g),s=="zoom"?(s="",_=0):d?(a.selection.moveToPosition(v),_=0,D()):s=="scroll"?(A(),R()):D(),clearTimeout(d),d=null},a),P.addListener(f,"touchmove",function(T){d&&(clearTimeout(d),d=null);var L=T.touches;if(!(L.length>1||s=="zoom")){var O=L[0],H=o-O.clientX,V=c-O.clientY;if(s=="wait")if(H*H+V*V>4)s="cursor";else return T.preventDefault();o=O.clientX,c=O.clientY,T.clientX=O.clientX,T.clientY=O.clientY;var W=T.timeStamp,K=W-h;if(h=W,s=="scroll"){var Q=new B(T,a);Q.speed=1,Q.wheelX=H,Q.wheelY=V,10*Math.abs(H)0)if(Ke==16){for(Ue=nt;Ue-1){for(Ue=nt;Ue=0&&oe[Ct]==b;Ct--)Y[Ct]=B}}}function K(J,Y,z){if(!(P=J){for(de=he+1;de=J;)de++;for(fe=he,le=de-1;fe=Y.length||(de=z[oe-1])!=g&&de!=_||(fe=Y[oe+1])!=g&&fe!=_?v:(C&&(fe=_),fe==de?fe:v);case N:return de=oe>0?z[oe-1]:k,de==g&&oe+10&&z[oe-1]==g)return g;if(C)return v;for(Re=oe+1,le=Y.length;Re=1425&&Ke<=2303||Ke==64286;if(de=Y[Re],vt&&(de==d||de==S))return d}return oe<1||(de=Y[oe-1])==k?v:z[oe-1];case k:return C=!1,f=!0,B;case I:return a=!0,v;case w:case F:case T:case L:case A:C=!1;case O:return v}}function ie(J){var Y=J.charCodeAt(0),z=Y>>8;return z==0?Y>191?h:H[Y]:z==5?/[\u0591-\u05f4]/.test(J)?d:h:z==6?/[\u0610-\u061a\u064b-\u065f\u06d6-\u06e4\u06e7-\u06ed]/.test(J)?R:/[\u0660-\u0669\u066b-\u066c]/.test(J)?_:Y==1642?D:/[\u06f0-\u06f9]/.test(J)?g:S:z==32&&Y<=8287?V[Y&255]:z==254&&Y>=65136?S:v}p.L=h,p.R=d,p.EN=g,p.ON_R=3,p.AN=4,p.R_H=5,p.B=6,p.RLE=7,p.DOT="·",p.doBidiReorder=function(J,Y,z){if(J.length<2)return{};var oe=J.split(""),he=new Array(oe.length),de=new Array(oe.length),fe=[];B=z?l:c,W(oe,fe,oe.length,Y);for(var le=0;leS&&Y[le]0&&oe[le-1]==="ل"&&/\u0622|\u0623|\u0625|\u0627/.test(oe[le])&&(fe[le-1]=fe[le]=p.R_H,le++);oe[oe.length-1]===p.DOT&&(fe[oe.length-1]=p.B),oe[0]==="‫"&&(fe[0]=p.RLE);for(var le=0;le=0&&(s=this.session.$docRowCache[c])}return s},a.prototype.getSplitIndex=function(){var s=0,o=this.session.$screenRowCache;if(o.length)for(var c,l=this.session.$getRowCacheIndex(o,this.currentRow);this.currentRow-s>0&&(c=this.session.$getRowCacheIndex(o,this.currentRow-s-1),c===l);)l=c,s++;else s=this.currentRow;return s},a.prototype.updateRowLine=function(s,o){s===void 0&&(s=this.getDocumentRow());var c=s===this.session.getLength()-1,l=c?this.EOF:this.EOL;if(this.wrapIndent=0,this.line=this.session.getLine(s),this.isRtlDir=this.$isRtl||this.line.charAt(0)===this.RLE,this.session.$useWrapMode){var h=this.session.$wrapData[s];h&&(o===void 0&&(o=this.getSplitIndex()),o>0&&h.length?(this.wrapIndent=h.indent,this.wrapOffset=this.wrapIndent*this.charWidths[B.L],this.line=oo?this.session.getOverwrite()?s:s-1:o,l=B.getVisualFromLogicalIdx(c,this.bidiMap),h=this.bidiMap.bidiLevels,d=0;!this.session.getOverwrite()&&s<=o&&h[l]%2!==0&&l++;for(var g=0;go&&h[l]%2===0&&(d+=this.charWidths[h[l]]),this.wrapIndent&&(d+=this.isRtlDir?-1*this.wrapOffset:this.wrapOffset),this.isRtlDir&&(d+=this.rtlLineOffset),d},a.prototype.getSelections=function(s,o){var c=this.bidiMap,l=c.bidiLevels,h,d=[],g=0,_=Math.min(s,o)-this.wrapIndent,v=Math.max(s,o)-this.wrapIndent,k=!1,I=!1,S=0;this.wrapIndent&&(g+=this.isRtlDir?-1*this.wrapOffset:this.wrapOffset);for(var b,x=0;x=_&&bl+g/2;){if(l+=g,h===d.length-1){g=0;break}g=this.charWidths[d[++h]]}return h>0&&d[h-1]%2!==0&&d[h]%2===0?(c0&&d[h-1]%2===0&&d[h]%2!==0?o=1+(c>l?this.bidiMap.logicalFromVisual[h]:this.bidiMap.logicalFromVisual[h-1]):this.isRtlDir&&h===d.length-1&&g===0&&d[h-1]%2===0||!this.isRtlDir&&h===0&&d[h]%2!==0?o=1+this.bidiMap.logicalFromVisual[h]:(h>0&&d[h-1]%2!==0&&g!==0&&h--,o=this.bidiMap.logicalFromVisual[h]),o===0&&this.isRtlDir&&o++,o+this.wrapIndent},a}();p.BidiHandler=f}),ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"],function(r,p,m){var B=r("./lib/oop"),P=r("./lib/lang"),C=r("./lib/event_emitter").EventEmitter,f=r("./range").Range,a=function(s){this.session=s,this.doc=s.getDocument(),this.clearSelection(),this.cursor=this.lead=this.doc.createAnchor(0,0),this.anchor=this.doc.createAnchor(0,0),this.$silent=!1;var o=this;this.cursor.on("change",function(c){o.$cursorChanged=!0,o.$silent||o._emit("changeCursor"),!o.$isEmpty&&!o.$silent&&o._emit("changeSelection"),!o.$keepDesiredColumnOnChange&&c.old.column!=c.value.column&&(o.$desiredColumn=null)}),this.anchor.on("change",function(){o.$anchorChanged=!0,!o.$isEmpty&&!o.$silent&&o._emit("changeSelection")})};(function(){B.implement(this,C),this.isEmpty=function(){return this.$isEmpty||this.anchor.row==this.lead.row&&this.anchor.column==this.lead.column},this.isMultiLine=function(){return!this.$isEmpty&&this.anchor.row!=this.cursor.row},this.getCursor=function(){return this.lead.getPosition()},this.setAnchor=function(s,o){this.$isEmpty=!1,this.anchor.setPosition(s,o)},this.setSelectionAnchor=this.setAnchor,this.getAnchor=function(){return this.$isEmpty?this.getSelectionLead():this.anchor.getPosition()},this.getSelectionAnchor=this.getAnchor,this.getSelectionLead=function(){return this.lead.getPosition()},this.isBackwards=function(){var s=this.anchor,o=this.lead;return s.row>o.row||s.row==o.row&&s.column>o.column},this.getRange=function(){var s=this.anchor,o=this.lead;return this.$isEmpty?f.fromPoints(o,o):this.isBackwards()?f.fromPoints(o,s):f.fromPoints(s,o)},this.clearSelection=function(){this.$isEmpty||(this.$isEmpty=!0,this._emit("changeSelection"))},this.selectAll=function(){this.$setSelection(0,0,Number.MAX_VALUE,Number.MAX_VALUE)},this.setRange=this.setSelectionRange=function(s,o){var c=o?s.end:s.start,l=o?s.start:s.end;this.$setSelection(c.row,c.column,l.row,l.column)},this.$setSelection=function(s,o,c,l){if(!this.$silent){var h=this.$isEmpty,d=this.inMultiSelectMode;this.$silent=!0,this.$cursorChanged=this.$anchorChanged=!1,this.anchor.setPosition(s,o),this.cursor.setPosition(c,l),this.$isEmpty=!f.comparePoints(this.anchor,this.cursor),this.$silent=!1,this.$cursorChanged&&this._emit("changeCursor"),(this.$cursorChanged||this.$anchorChanged||h!=this.$isEmpty||d)&&this._emit("changeSelection")}},this.$moveSelection=function(s){var o=this.lead;this.$isEmpty&&this.setSelectionAnchor(o.row,o.column),s.call(this)},this.selectTo=function(s,o){this.$moveSelection(function(){this.moveCursorTo(s,o)})},this.selectToPosition=function(s){this.$moveSelection(function(){this.moveCursorToPosition(s)})},this.moveTo=function(s,o){this.clearSelection(),this.moveCursorTo(s,o)},this.moveToPosition=function(s){this.clearSelection(),this.moveCursorToPosition(s)},this.selectUp=function(){this.$moveSelection(this.moveCursorUp)},this.selectDown=function(){this.$moveSelection(this.moveCursorDown)},this.selectRight=function(){this.$moveSelection(this.moveCursorRight)},this.selectLeft=function(){this.$moveSelection(this.moveCursorLeft)},this.selectLineStart=function(){this.$moveSelection(this.moveCursorLineStart)},this.selectLineEnd=function(){this.$moveSelection(this.moveCursorLineEnd)},this.selectFileEnd=function(){this.$moveSelection(this.moveCursorFileEnd)},this.selectFileStart=function(){this.$moveSelection(this.moveCursorFileStart)},this.selectWordRight=function(){this.$moveSelection(this.moveCursorWordRight)},this.selectWordLeft=function(){this.$moveSelection(this.moveCursorWordLeft)},this.getWordRange=function(s,o){if(typeof o>"u"){var c=s||this.lead;s=c.row,o=c.column}return this.session.getWordRange(s,o)},this.selectWord=function(){this.setSelectionRange(this.getWordRange())},this.selectAWord=function(){var s=this.getCursor(),o=this.session.getAWordRange(s.row,s.column);this.setSelectionRange(o)},this.getLineRange=function(s,o){var c=typeof s=="number"?s:this.lead.row,l,h=this.session.getFoldLine(c);return h?(c=h.start.row,l=h.end.row):l=c,o===!0?new f(c,0,l,this.session.getLine(l).length):new f(c,0,l+1,0)},this.selectLine=function(){this.setSelectionRange(this.getLineRange())},this.moveCursorUp=function(){this.moveCursorBy(-1,0)},this.moveCursorDown=function(){this.moveCursorBy(1,0)},this.wouldMoveIntoSoftTab=function(s,o,c){var l=s.column,h=s.column+o;return c<0&&(l=s.column-o,h=s.column),this.session.isTabStop(s)&&this.doc.getLine(s.row).slice(l,h).split(" ").length-1==o},this.moveCursorLeft=function(){var s=this.lead.getPosition(),o;if(o=this.session.getFoldAt(s.row,s.column,-1))this.moveCursorTo(o.start.row,o.start.column);else if(s.column===0)s.row>0&&this.moveCursorTo(s.row-1,this.doc.getLine(s.row-1).length);else{var c=this.session.getTabSize();this.wouldMoveIntoSoftTab(s,c,-1)&&!this.session.getNavigateWithinSoftTabs()?this.moveCursorBy(0,-c):this.moveCursorBy(0,-1)}},this.moveCursorRight=function(){var s=this.lead.getPosition(),o;if(o=this.session.getFoldAt(s.row,s.column,1))this.moveCursorTo(o.end.row,o.end.column);else if(this.lead.column==this.doc.getLine(this.lead.row).length)this.lead.row0&&(o.column=l)}}this.moveCursorTo(o.row,o.column)},this.moveCursorFileEnd=function(){var s=this.doc.getLength()-1,o=this.doc.getLine(s).length;this.moveCursorTo(s,o)},this.moveCursorFileStart=function(){this.moveCursorTo(0,0)},this.moveCursorLongWordRight=function(){var s=this.lead.row,o=this.lead.column,c=this.doc.getLine(s),l=c.substring(o);this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;var h=this.session.getFoldAt(s,o,1);if(h){this.moveCursorTo(h.end.row,h.end.column);return}if(this.session.nonTokenRe.exec(l)&&(o+=this.session.nonTokenRe.lastIndex,this.session.nonTokenRe.lastIndex=0,l=c.substring(o)),o>=c.length){this.moveCursorTo(s,c.length),this.moveCursorRight(),s0&&this.moveCursorWordLeft();return}this.session.tokenRe.exec(h)&&(o-=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0),this.moveCursorTo(s,o)},this.$shortWordEndIndex=function(s){var o=0,c,l=/\s/,h=this.session.tokenRe;if(h.lastIndex=0,this.session.tokenRe.exec(s))o=this.session.tokenRe.lastIndex;else{for(;(c=s[o])&&l.test(c);)o++;if(o<1){for(h.lastIndex=0;(c=s[o])&&!h.test(c);)if(h.lastIndex=0,o++,l.test(c))if(o>2){o--;break}else{for(;(c=s[o])&&l.test(c);)o++;if(o>2)break}}}return h.lastIndex=0,o},this.moveCursorShortWordRight=function(){var s=this.lead.row,o=this.lead.column,c=this.doc.getLine(s),l=c.substring(o),h=this.session.getFoldAt(s,o,1);if(h)return this.moveCursorTo(h.end.row,h.end.column);if(o==c.length){var d=this.doc.getLength();do s++,l=this.doc.getLine(s);while(s0&&/^\s*$/.test(l));o=l.length,/\s+$/.test(l)||(l="")}var h=P.stringReverse(l),d=this.$shortWordEndIndex(h);return this.moveCursorTo(s,o-d)},this.moveCursorWordRight=function(){this.session.$selectLongWords?this.moveCursorLongWordRight():this.moveCursorShortWordRight()},this.moveCursorWordLeft=function(){this.session.$selectLongWords?this.moveCursorLongWordLeft():this.moveCursorShortWordLeft()},this.moveCursorBy=function(s,o){var c=this.session.documentToScreenPosition(this.lead.row,this.lead.column),l;if(o===0&&(s!==0&&(this.session.$bidiHandler.isBidiRow(c.row,this.lead.row)?(l=this.session.$bidiHandler.getPosLeft(c.column),c.column=Math.round(l/this.session.$bidiHandler.charWidths[0])):l=c.column*this.session.$bidiHandler.charWidths[0]),this.$desiredColumn?c.column=this.$desiredColumn:this.$desiredColumn=c.column),s!=0&&this.session.lineWidgets&&this.session.lineWidgets[this.lead.row]){var h=this.session.lineWidgets[this.lead.row];s<0?s-=h.rowsAbove||0:s>0&&(s+=h.rowCount-(h.rowsAbove||0))}var d=this.session.screenToDocumentPosition(c.row+s,c.column,l);s!==0&&o===0&&d.row===this.lead.row&&(d.column,this.lead.column),this.moveCursorTo(d.row,d.column+o,o===0)},this.moveCursorToPosition=function(s){this.moveCursorTo(s.row,s.column)},this.moveCursorTo=function(s,o,c){var l=this.session.getFoldAt(s,o,1);l&&(s=l.start.row,o=l.start.column),this.$keepDesiredColumnOnChange=!0;var h=this.session.getLine(s);/[\uDC00-\uDFFF]/.test(h.charAt(o))&&h.charAt(o-1)&&(this.lead.row==s&&this.lead.column==o+1?o=o-1:o=o+1),this.lead.setPosition(s,o),this.$keepDesiredColumnOnChange=!1,c||(this.$desiredColumn=null)},this.moveCursorToScreen=function(s,o,c){var l=this.session.screenToDocumentPosition(s,o);this.moveCursorTo(l.row,l.column,c)},this.detach=function(){this.lead.detach(),this.anchor.detach()},this.fromOrientedRange=function(s){this.setSelectionRange(s,s.cursor==s.start),this.$desiredColumn=s.desiredColumn||this.$desiredColumn},this.toOrientedRange=function(s){var o=this.getRange();return s?(s.start.column=o.start.column,s.start.row=o.start.row,s.end.column=o.end.column,s.end.row=o.end.row):s=o,s.cursor=this.isBackwards()?s.start:s.end,s.desiredColumn=this.$desiredColumn,s},this.getRangeOfMovements=function(s){var o=this.getCursor();try{s(this);var c=this.getCursor();return f.fromPoints(o,c)}catch{return f.fromPoints(o,o)}finally{this.moveCursorToPosition(o)}},this.toJSON=function(){if(this.rangeCount)var s=this.ranges.map(function(o){var c=o.clone();return c.isBackwards=o.cursor==o.start,c});else{var s=this.getRange();s.isBackwards=this.isBackwards()}return s},this.fromJSON=function(s){if(s.start==null)if(this.rangeList&&s.length>1){this.toSingleRange(s[0]);for(var o=s.length;o--;){var c=f.fromPoints(s[o].start,s[o].end);s[o].isBackwards&&(c.cursor=c.start),this.addRange(c,!0)}return}else s=s[0];this.rangeList&&this.toSingleRange(s),this.setSelectionRange(s,s.isBackwards)},this.isEqual=function(s){if((s.length||this.rangeCount)&&s.length!=this.rangeCount)return!1;if(!s.length||!this.ranges)return this.getRange().isEqual(s);for(var o=this.ranges.length;o--;)if(!this.ranges[o].isEqual(s[o]))return!1;return!0}}).call(a.prototype),p.Selection=a}),ace.define("ace/tokenizer",["require","exports","module","ace/config"],function(r,p,m){var B=r("./config"),P=2e3,C=function(){function f(a){this.states=a,this.regExps={},this.matchMappings={};for(var s in this.states){for(var o=this.states[s],c=[],l=0,h=this.matchMappings[s]={defaultToken:"text"},d="g",g=[],_=0;_1?v.onMatch=this.$applyToken:v.onMatch=v.token),I>1&&(/\\\d/.test(v.regex)?k=v.regex.replace(/\\([0-9]+)/g,function(S,b){return"\\"+(parseInt(b,10)+l+1)}):(I=1,k=this.removeCapturingGroups(v.regex)),!v.splitRegex&&typeof v.token!="string"&&g.push(v)),h[l]=_,l+=I,c.push(k),v.onMatch||(v.onMatch=null)}}c.length||(h[0]=0,c.push("$")),g.forEach(function(S){S.splitRegex=this.createSplitterRegexp(S.regex,d)},this),this.regExps[s]=new RegExp("("+c.join(")|(")+")|($)",d)}}return f.prototype.$setMaxTokenCount=function(a){P=a|0},f.prototype.$applyToken=function(a){var s=this.splitRegex.exec(a).slice(1),o=this.token.apply(this,s);if(typeof o=="string")return[{type:o,value:a}];for(var c=[],l=0,h=o.length;lv){var D=a.substring(v,N-x.length);I.type==S?I.value+=D:(I.type&&_.push(I),I={type:S,value:D})}for(var R=0;RP){for(k>2*a.length&&this.reportError("infinite loop with in ace tokenizer",{startState:s,line:a});v1&&o[0]!==c&&o.unshift("#tmp",c),{tokens:_,state:o.length?o:c}},f}();C.prototype.reportError=B.reportError,p.Tokenizer=C}),ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"],function(r,p,m){var B=r("../lib/lang"),P=function(){this.$rules={start:[{token:"empty_line",regex:"^$"},{defaultToken:"text"}]}};(function(){this.addRules=function(a,s){if(!s){for(var o in a)this.$rules[o]=a[o];return}for(var o in a){for(var c=a[o],l=0;l=this.$rowTokens.length;){if(this.$row+=1,f||(f=this.$session.getLength()),this.$row>=f)return this.$row=f-1,null;this.$rowTokens=this.$session.getTokens(this.$row),this.$tokenIndex=0}return this.$rowTokens[this.$tokenIndex]},C.prototype.getCurrentToken=function(){return this.$rowTokens[this.$tokenIndex]},C.prototype.getCurrentTokenRow=function(){return this.$row},C.prototype.getCurrentTokenColumn=function(){var f=this.$rowTokens,a=this.$tokenIndex,s=f[a].start;if(s!==void 0)return s;for(s=0;a>0;)a-=1,s+=f[a].value.length;return s},C.prototype.getCurrentTokenPosition=function(){return{row:this.$row,column:this.getCurrentTokenColumn()}},C.prototype.getCurrentTokenRange=function(){var f=this.$rowTokens[this.$tokenIndex],a=this.getCurrentTokenColumn();return new B(this.$row,a,this.$row,a+f.value.length)},C}();p.TokenIterator=P}),ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],function(r,p,m){var B=r("../../lib/oop"),P=r("../behaviour").Behaviour,C=r("../../token_iterator").TokenIterator,f=r("../../lib/lang"),a=["text","paren.rparen","rparen","paren","punctuation.operator"],s=["text","paren.rparen","rparen","paren","punctuation.operator","comment"],o,c={},l={'"':'"',"'":"'"},h=function(_){var v=-1;if(_.multiSelect&&(v=_.selection.index,c.rangeCount!=_.multiSelect.rangeCount&&(c={rangeCount:_.multiSelect.rangeCount})),c[v])return o=c[v];o=c[v]={autoInsertedBrackets:0,autoInsertedRow:-1,autoInsertedLineEnd:"",maybeInsertedBrackets:0,maybeInsertedRow:-1,maybeInsertedLineStart:"",maybeInsertedLineEnd:""}},d=function(_,v,k,I){var S=_.end.row-_.start.row;return{text:k+v+I,selection:[0,_.start.column+1,S,_.end.column+(S?0:1)]}},g=function(_){_=_||{},this.add("braces","insertion",function(v,k,I,S,b){var x=I.getCursorPosition(),N=S.doc.getLine(x.row);if(b=="{"){h(I);var D=I.getSelectionRange(),R=S.doc.getTextRange(D);if(R!==""&&R!=="{"&&I.getWrapBehavioursEnabled())return d(D,R,"{","}");if(g.isSaneInsertion(I,S))return/[\]\}\)]/.test(N[x.column])||I.inMultiSelectMode||_.braces?(g.recordAutoInsert(I,S,"}"),{text:"{}",selection:[1,1]}):(g.recordMaybeInsert(I,S,"{"),{text:"{",selection:[1,1]})}else if(b=="}"){h(I);var w=N.substring(x.column,x.column+1);if(w=="}"){var F=S.$findOpeningBracket("}",{column:x.column+1,row:x.row});if(F!==null&&g.isAutoInsertedClosing(x,N,b))return g.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}else if(b==` -`||b==`\r -`){h(I);var A="";g.isMaybeInsertedClosing(x,N)&&(A=f.stringRepeat("}",o.maybeInsertedBrackets),g.clearMaybeInsertedClosing());var w=N.substring(x.column,x.column+1);if(w==="}"){var T=S.findMatchingBracket({row:x.row,column:x.column+1},"}");if(!T)return null;var L=this.$getIndent(S.getLine(T.row))}else if(A)var L=this.$getIndent(N);else{g.clearMaybeInsertedClosing();return}var O=L+S.getTabString();return{text:` -`+O+` -`+L+A,selection:[1,O.length,1,O.length]}}else g.clearMaybeInsertedClosing()}),this.add("braces","deletion",function(v,k,I,S,b){var x=S.doc.getTextRange(b);if(!b.isMultiLine()&&x=="{"){h(I);var N=S.doc.getLine(b.start.row),D=N.substring(b.end.column,b.end.column+1);if(D=="}")return b.end.column++,b;o.maybeInsertedBrackets--}}),this.add("parens","insertion",function(v,k,I,S,b){if(b=="("){h(I);var x=I.getSelectionRange(),N=S.doc.getTextRange(x);if(N!==""&&I.getWrapBehavioursEnabled())return d(x,N,"(",")");if(g.isSaneInsertion(I,S))return g.recordAutoInsert(I,S,")"),{text:"()",selection:[1,1]}}else if(b==")"){h(I);var D=I.getCursorPosition(),R=S.doc.getLine(D.row),w=R.substring(D.column,D.column+1);if(w==")"){var F=S.$findOpeningBracket(")",{column:D.column+1,row:D.row});if(F!==null&&g.isAutoInsertedClosing(D,R,b))return g.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(v,k,I,S,b){var x=S.doc.getTextRange(b);if(!b.isMultiLine()&&x=="("){h(I);var N=S.doc.getLine(b.start.row),D=N.substring(b.start.column+1,b.start.column+2);if(D==")")return b.end.column++,b}}),this.add("brackets","insertion",function(v,k,I,S,b){if(b=="["){h(I);var x=I.getSelectionRange(),N=S.doc.getTextRange(x);if(N!==""&&I.getWrapBehavioursEnabled())return d(x,N,"[","]");if(g.isSaneInsertion(I,S))return g.recordAutoInsert(I,S,"]"),{text:"[]",selection:[1,1]}}else if(b=="]"){h(I);var D=I.getCursorPosition(),R=S.doc.getLine(D.row),w=R.substring(D.column,D.column+1);if(w=="]"){var F=S.$findOpeningBracket("]",{column:D.column+1,row:D.row});if(F!==null&&g.isAutoInsertedClosing(D,R,b))return g.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("brackets","deletion",function(v,k,I,S,b){var x=S.doc.getTextRange(b);if(!b.isMultiLine()&&x=="["){h(I);var N=S.doc.getLine(b.start.row),D=N.substring(b.start.column+1,b.start.column+2);if(D=="]")return b.end.column++,b}}),this.add("string_dquotes","insertion",function(v,k,I,S,b){var x=S.$mode.$quotes||l;if(b.length==1&&x[b]){if(this.lineCommentStart&&this.lineCommentStart.indexOf(b)!=-1)return;h(I);var N=b,D=I.getSelectionRange(),R=S.doc.getTextRange(D);if(R!==""&&(R.length!=1||!x[R])&&I.getWrapBehavioursEnabled())return d(D,R,N,N);if(!R){var w=I.getCursorPosition(),F=S.doc.getLine(w.row),A=F.substring(w.column-1,w.column),T=F.substring(w.column,w.column+1),L=S.getTokenAt(w.row,w.column),O=S.getTokenAt(w.row,w.column+1);if(A=="\\"&&L&&/escape/.test(L.type))return null;var H=L&&/string|escape/.test(L.type),V=!O||/string|escape/.test(O.type),W;if(T==N)W=H!==V,W&&/string\.end/.test(O.type)&&(W=!1);else{if(H&&!V||H&&V)return null;var K=S.$mode.tokenRe;K.lastIndex=0;var Q=K.test(A);K.lastIndex=0;var ie=K.test(T),J=S.$mode.$pairQuotesAfter,Y=J&&J[N]&&J[N].test(A);if(!Y&&Q||ie||T&&!/[\s;,.})\]\\]/.test(T))return null;var z=F[w.column-2];if(A==N&&(z==N||K.test(z)))return null;W=!0}return{text:W?N+N:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(v,k,I,S,b){var x=S.$mode.$quotes||l,N=S.doc.getTextRange(b);if(!b.isMultiLine()&&x.hasOwnProperty(N)){h(I);var D=S.doc.getLine(b.start.row),R=D.substring(b.start.column+1,b.start.column+2);if(R==N)return b.end.column++,b}}),_.closeDocComment!==!1&&this.add("doc comment end","insertion",function(v,k,I,S,b){if(v==="doc-start"&&(b===` -`||b===`\r -`)&&I.selection.isEmpty()){var x=I.getCursorPosition(),N=S.doc.getLine(x.row),D=S.doc.getLine(x.row+1),R=this.$getIndent(N);if(/\s*\*/.test(D))return/^\s*\*/.test(N)?{text:b+R+"* ",selection:[1,3+R.length,1,3+R.length]}:{text:b+R+" * ",selection:[1,3+R.length,1,3+R.length]};if(/\/\*\*/.test(N.substring(0,x.column)))return{text:b+R+" * "+b+" "+R+"*/",selection:[1,4+R.length,1,4+R.length]}}})};g.isSaneInsertion=function(_,v){var k=_.getCursorPosition(),I=new C(v,k.row,k.column);if(!this.$matchTokenType(I.getCurrentToken()||"text",a)){if(/[)}\]]/.test(_.session.getLine(k.row)[k.column]))return!0;var S=new C(v,k.row,k.column+1);if(!this.$matchTokenType(S.getCurrentToken()||"text",a))return!1}return I.stepForward(),I.getCurrentTokenRow()!==k.row||this.$matchTokenType(I.getCurrentToken()||"text",s)},g.$matchTokenType=function(_,v){return v.indexOf(_.type||_)>-1},g.recordAutoInsert=function(_,v,k){var I=_.getCursorPosition(),S=v.doc.getLine(I.row);this.isAutoInsertedClosing(I,S,o.autoInsertedLineEnd[0])||(o.autoInsertedBrackets=0),o.autoInsertedRow=I.row,o.autoInsertedLineEnd=k+S.substr(I.column),o.autoInsertedBrackets++},g.recordMaybeInsert=function(_,v,k){var I=_.getCursorPosition(),S=v.doc.getLine(I.row);this.isMaybeInsertedClosing(I,S)||(o.maybeInsertedBrackets=0),o.maybeInsertedRow=I.row,o.maybeInsertedLineStart=S.substr(0,I.column)+k,o.maybeInsertedLineEnd=S.substr(I.column),o.maybeInsertedBrackets++},g.isAutoInsertedClosing=function(_,v,k){return o.autoInsertedBrackets>0&&_.row===o.autoInsertedRow&&k===o.autoInsertedLineEnd[0]&&v.substr(_.column)===o.autoInsertedLineEnd},g.isMaybeInsertedClosing=function(_,v){return o.maybeInsertedBrackets>0&&_.row===o.maybeInsertedRow&&v.substr(_.column)===o.maybeInsertedLineEnd&&v.substr(0,_.column)==o.maybeInsertedLineStart},g.popAutoInsertedClosing=function(){o.autoInsertedLineEnd=o.autoInsertedLineEnd.substr(1),o.autoInsertedBrackets--},g.clearMaybeInsertedClosing=function(){o&&(o.maybeInsertedBrackets=0,o.maybeInsertedRow=-1)},B.inherits(g,P),p.CstyleBehaviour=g}),ace.define("ace/unicode",["require","exports","module"],function(r,p,m){for(var B=[48,9,8,25,5,0,2,25,48,0,11,0,5,0,6,22,2,30,2,457,5,11,15,4,8,0,2,0,18,116,2,1,3,3,9,0,2,2,2,0,2,19,2,82,2,138,2,4,3,155,12,37,3,0,8,38,10,44,2,0,2,1,2,1,2,0,9,26,6,2,30,10,7,61,2,9,5,101,2,7,3,9,2,18,3,0,17,58,3,100,15,53,5,0,6,45,211,57,3,18,2,5,3,11,3,9,2,1,7,6,2,2,2,7,3,1,3,21,2,6,2,0,4,3,3,8,3,1,3,3,9,0,5,1,2,4,3,11,16,2,2,5,5,1,3,21,2,6,2,1,2,1,2,1,3,0,2,4,5,1,3,2,4,0,8,3,2,0,8,15,12,2,2,8,2,2,2,21,2,6,2,1,2,4,3,9,2,2,2,2,3,0,16,3,3,9,18,2,2,7,3,1,3,21,2,6,2,1,2,4,3,8,3,1,3,2,9,1,5,1,2,4,3,9,2,0,17,1,2,5,4,2,2,3,4,1,2,0,2,1,4,1,4,2,4,11,5,4,4,2,2,3,3,0,7,0,15,9,18,2,2,7,2,2,2,22,2,9,2,4,4,7,2,2,2,3,8,1,2,1,7,3,3,9,19,1,2,7,2,2,2,22,2,9,2,4,3,8,2,2,2,3,8,1,8,0,2,3,3,9,19,1,2,7,2,2,2,22,2,15,4,7,2,2,2,3,10,0,9,3,3,9,11,5,3,1,2,17,4,23,2,8,2,0,3,6,4,0,5,5,2,0,2,7,19,1,14,57,6,14,2,9,40,1,2,0,3,1,2,0,3,0,7,3,2,6,2,2,2,0,2,0,3,1,2,12,2,2,3,4,2,0,2,5,3,9,3,1,35,0,24,1,7,9,12,0,2,0,2,0,5,9,2,35,5,19,2,5,5,7,2,35,10,0,58,73,7,77,3,37,11,42,2,0,4,328,2,3,3,6,2,0,2,3,3,40,2,3,3,32,2,3,3,6,2,0,2,3,3,14,2,56,2,3,3,66,5,0,33,15,17,84,13,619,3,16,2,25,6,74,22,12,2,6,12,20,12,19,13,12,2,2,2,1,13,51,3,29,4,0,5,1,3,9,34,2,3,9,7,87,9,42,6,69,11,28,4,11,5,11,11,39,3,4,12,43,5,25,7,10,38,27,5,62,2,28,3,10,7,9,14,0,89,75,5,9,18,8,13,42,4,11,71,55,9,9,4,48,83,2,2,30,14,230,23,280,3,5,3,37,3,5,3,7,2,0,2,0,2,0,2,30,3,52,2,6,2,0,4,2,2,6,4,3,3,5,5,12,6,2,2,6,67,1,20,0,29,0,14,0,17,4,60,12,5,0,4,11,18,0,5,0,3,9,2,0,4,4,7,0,2,0,2,0,2,3,2,10,3,3,6,4,5,0,53,1,2684,46,2,46,2,132,7,6,15,37,11,53,10,0,17,22,10,6,2,6,2,6,2,6,2,6,2,6,2,6,2,6,2,31,48,0,470,1,36,5,2,4,6,1,5,85,3,1,3,2,2,89,2,3,6,40,4,93,18,23,57,15,513,6581,75,20939,53,1164,68,45,3,268,4,27,21,31,3,13,13,1,2,24,9,69,11,1,38,8,3,102,3,1,111,44,25,51,13,68,12,9,7,23,4,0,5,45,3,35,13,28,4,64,15,10,39,54,10,13,3,9,7,22,4,1,5,66,25,2,227,42,2,1,3,9,7,11171,13,22,5,48,8453,301,3,61,3,105,39,6,13,4,6,11,2,12,2,4,2,0,2,1,2,1,2,107,34,362,19,63,3,53,41,11,5,15,17,6,13,1,25,2,33,4,2,134,20,9,8,25,5,0,2,25,12,88,4,5,3,5,3,5,3,2],P=0,C=[],f=0;f2?z%b!=b-1:z%b==0}}else{if(!this.blockComment)return!1;var N=this.blockComment.start,D=this.blockComment.end,R=new RegExp("^(\\s*)(?:"+s.escapeRegExp(N)+")"),w=new RegExp("(?:"+s.escapeRegExp(D)+")\\s*$"),F=function(W,K){T(W,K)||(!k||/\S/.test(W))&&(v.insertInLine({row:K,column:W.length},D),v.insertInLine({row:K,column:S},N))},A=function(W,K){var Q;(Q=W.match(w))&&v.removeInLine(K,W.length-Q[0].length,W.length),(Q=W.match(R))&&v.removeInLine(K,Q[1].length,Q[0].length)},T=function(W,K){if(R.test(W))return!0;for(var Q=d.getTokens(K),ie=0;ieW.length&&(V=W.length)}),S==1/0&&(S=V,k=!1,I=!1),x&&S%b!=0&&(S=Math.floor(S/b)*b),H(I?A:F)},this.toggleBlockComment=function(h,d,g,_){var v=this.blockComment;if(v){!v.start&&v[0]&&(v=v[0]);var k=new o(d,_.row,_.column),I=k.getCurrentToken();d.selection;var S=d.selection.toOrientedRange(),b,x;if(I&&/comment/.test(I.type)){for(var N,D;I&&/comment/.test(I.type);){var R=I.value.indexOf(v.start);if(R!=-1){var w=k.getCurrentTokenRow(),F=k.getCurrentTokenColumn()+R;N=new c(w,F,w,F+v.start.length);break}I=k.stepBackward()}for(var k=new o(d,_.row,_.column),I=k.getCurrentToken();I&&/comment/.test(I.type);){var R=I.value.indexOf(v.end);if(R!=-1){var w=k.getCurrentTokenRow(),F=k.getCurrentTokenColumn()+R;D=new c(w,F,w,F+v.end.length);break}I=k.stepForward()}D&&d.remove(D),N&&(d.remove(N),b=N.start.row,x=-v.start.length)}else x=v.start.length,b=g.start.row,d.insert(g.end,v.end),d.insert(g.start,v.start);S.start.row==b&&(S.start.column+=x),S.end.row==b&&(S.end.column+=x),d.selection.fromOrientedRange(S)}},this.getNextLineIndent=function(h,d,g){return this.$getIndent(d)},this.checkOutdent=function(h,d,g){return!1},this.autoOutdent=function(h,d,g){},this.$getIndent=function(h){return h.match(/^\s*/)[0]},this.createWorker=function(h){return null},this.createModeDelegates=function(h){this.$embeds=[],this.$modes={};for(var d in h)if(h[d]){var g=h[d],_=g.prototype.$id,v=B.$modes[_];v||(B.$modes[_]=v=new g),B.$modes[d]||(B.$modes[d]=v),this.$embeds.push(d),this.$modes[d]=v}for(var k=["toggleBlockComment","toggleCommentLines","getNextLineIndent","checkOutdent","autoOutdent","transformAction","getCompletions"],d=0;d"u"?this.setPosition(c.row,c.column):this.setPosition(c,l)}return s.prototype.getPosition=function(){return this.$clipPositionToDocument(this.row,this.column)},s.prototype.getDocument=function(){return this.document},s.prototype.onChange=function(o){if(!(o.start.row==o.end.row&&o.start.row!=this.row)&&!(o.start.row>this.row)){var c=a(o,{row:this.row,column:this.column},this.$insertRight);this.setPosition(c.row,c.column,!0)}},s.prototype.setPosition=function(o,c,l){var h;if(l?h={row:o,column:c}:h=this.$clipPositionToDocument(o,c),!(this.row==h.row&&this.column==h.column)){var d={row:this.row,column:this.column};this.row=h.row,this.column=h.column,this._signal("change",{old:d,value:h})}},s.prototype.detach=function(){this.document.off("change",this.$onChange)},s.prototype.attach=function(o){this.document=o||this.document,this.document.on("change",this.$onChange)},s.prototype.$clipPositionToDocument=function(o,c){var l={};return o>=this.document.getLength()?(l.row=Math.max(0,this.document.getLength()-1),l.column=this.document.getLine(l.row).length):o<0?(l.row=0,l.column=0):(l.row=o,l.column=Math.min(this.document.getLine(l.row).length,Math.max(0,c))),c<0&&(l.column=0),l},s}();C.prototype.$insertRight=!1,B.implement(C.prototype,P);function f(s,o,c){var l=c?s.column<=o.column:s.column=O.length&&ae.value===O&&O&&ae.selectionEnd!==H},ie=function(ae){R||(N?N=!1:Q(x)?(w.selectAll(),K()):M&&x.selectionStart!=k&&K())};function J(ae){if((!x||!x.parentNode)&&document.removeEventListener("selectionchange",J),!R&&x.selectionStart===x.selectionEnd){var ue=x.selectionStart-k,be=H-k;ue>0?ue=Math.max(ue-be,1):ue===0&&be&&(ue=-1);for(var Ne=Math.abs(ue),Be=ue>0?d.right:d.left,Ve=0;Ve0&&O[U]==ae[U];)U++,Be--;for(Qe=Qe.slice(U),U=1;Ve>0&&O.length-U>k-1&&O[O.length-U]==ae[ae.length-U];)U++,Ve--;We-=U-1,L-=U-1;var j=Qe.length-U+1;if(j<0&&(Be=-j,j=0),Qe=Qe.slice(0,j),!ue&&!Qe&&!We&&!Be&&!Ve&&!L)return"";S=!0;var ne=!1;return C.isAndroid&&Qe==". "&&(Qe=" ",ne=!0),Qe&&!Be&&!Ve&&!We&&!L||A?w.onTextInput(Qe):w.onTextInput(Qe,{extendLeft:Be,extendRight:Ve,restoreStart:We,restoreEnd:L}),S=!1,O=ae,k=be,H=Ne,V=L,ne?` +`:Qe},he=function(ae){if(R)return nt();if(ae&&ae.inputType){if(ae.inputType=="historyUndo")return w.execCommand("undo");if(ae.inputType=="historyRedo")return w.execCommand("redo")}var ue=x.value,be=oe(ue,!0);(ue.length>h+100||v.test(be)||M&&k<1&&k==H)&&K()},de=function(ae,ue,be){var Ne=ae.clipboardData||window.clipboardData;if(!(!Ne||o)){var Be=c||be?"Text":"text/plain";try{return ue?Ne.setData(Be,ue)!==!1:Ne.getData(Be)}catch(Ve){if(!be)return de(Ve,ue,!0)}}},fe=function(ae,ue){var be=w.getCopyText();if(!be)return B.preventDefault(ae);de(ae,be)?(_&&(K(be),N=be,setTimeout(function(){N=!1},10)),ue?w.onCut():w.onCopy(),B.preventDefault(ae)):(N=!0,x.value=be,x.select(),setTimeout(function(){N=!1,K(),ue?w.onCut():w.onCopy()}))},le=function(ae){fe(ae,!0)},Re=function(ae){fe(ae,!1)},je=function(ae){var ue=de(ae);r.pasteCancelled()||(typeof ue=="string"?(ue&&w.onPaste(ue,ae),C.isIE&&setTimeout(K),B.preventDefault(ae)):(x.value="",D=!0))};B.addCommandKeyListener(x,w.onCommandKey.bind(w),w),B.addListener(x,"select",ie,w),B.addListener(x,"input",he,w),B.addListener(x,"cut",le,w),B.addListener(x,"copy",Re,w),B.addListener(x,"paste",je,w),(!("oncut"in x)||!("oncopy"in x)||!("onpaste"in x))&&B.addListener(I,"keydown",function(ae){if(!(C.isMac&&!ae.metaKey||!ae.ctrlKey))switch(ae.keyCode){case 67:Re(ae);break;case 86:je(ae);break;case 88:le(ae);break}},w);var vt=function(ae){if(!(R||!w.onCompositionStart||w.$readOnly)&&(R={},!A)){ae.data&&(R.useTextareaForIME=!1),setTimeout(nt,0),w._signal("compositionStart"),w.on("mousedown",De);var ue=w.getSelectionRange();ue.end.row=ue.start.row,ue.end.column=ue.start.column,R.markerRange=ue,R.selectionStart=k,w.onCompositionStart(R),R.useTextareaForIME?(O=x.value="",k=0,H=0):(x.msGetInputContext&&(R.context=x.msGetInputContext()),x.getInputContext&&(R.context=x.getInputContext()))}},nt=function(){if(!(!R||!w.onCompositionUpdate||w.$readOnly)){if(A)return De();if(R.useTextareaForIME)w.onCompositionUpdate(x.value);else{var ae=x.value;oe(ae),R.markerRange&&(R.context&&(R.markerRange.start.column=R.selectionStart=R.context.compositionStartOffset),R.markerRange.end.column=R.markerRange.start.column+H-R.selectionStart+V)}}},Ue=function(ae){!w.onCompositionEnd||w.$readOnly||(R=!1,w.onCompositionEnd(),w.off("mousedown",De),ae&&he())};function De(){E=!0,x.blur(),x.focus(),E=!1}var Pt=a.delayedCall(nt,50).schedule.bind(null,null);function Ct(ae){ae.keyCode==27&&x.value.lengthH&&O[L]==` +`?U=d.end:WeH&&O.slice(0,L).split(` +`).length>2?U=d.down:L>H&&O[L-1]==" "?(U=d.right,j=g.option):(L>H||L==H&&H!=k&&We==L)&&(U=d.right),We!==L&&(j|=g.shift),U){var ne=ue.onCommandKey({},j,U);if(!ne&&ue.commands){U=d.keyCodeToString(U);var se=ue.commands.findKeyCommand(j,U);se&&ue.execCommand(se)}k=We,H=L,K("")}}};document.addEventListener("selectionchange",Ve),ue.on("destroy",function(){document.removeEventListener("selectionchange",Ve)})}this.destroy=function(){x.parentElement&&x.parentElement.removeChild(x)}};p.TextInput=y,p.$setUserAgentForTests=function(I,w){M=I,_=w}}),ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/useragent"],function(s,p,m){var B=s("../lib/useragent"),P=0,C=550,f=function(){function o(c){c.$clickSelection=null;var l=c.editor;l.setDefaultHandler("mousedown",this.onMouseDown.bind(c)),l.setDefaultHandler("dblclick",this.onDoubleClick.bind(c)),l.setDefaultHandler("tripleclick",this.onTripleClick.bind(c)),l.setDefaultHandler("quadclick",this.onQuadClick.bind(c)),l.setDefaultHandler("mousewheel",this.onMouseWheel.bind(c));var h=["select","startSelect","selectEnd","selectAllEnd","selectByWordsEnd","selectByLinesEnd","dragWait","dragWaitEnd","focusWait"];h.forEach(function(d){c[d]=this[d]},this),c.selectByLines=this.extendSelectionBy.bind(c,"getLineRange"),c.selectByWords=this.extendSelectionBy.bind(c,"getWordRange")}return o.prototype.onMouseDown=function(c){var l=c.inSelection(),h=c.getDocumentPosition();this.mousedownEvent=c;var d=this.editor,g=c.getButton();if(g!==0){var _=d.getSelectionRange(),v=_.isEmpty();(v||g==1)&&d.selection.moveToPosition(h),g==2&&(d.textInput.onContextMenu(c.domEvent),B.isMozilla||c.preventDefault());return}if(this.mousedownEvent.time=Date.now(),l&&!d.isFocused()&&(d.focus(),this.$focusTimeout&&!this.$clickSelection&&!d.inMultiSelectMode)){this.setState("focusWait"),this.captureMouse(c);return}return this.captureMouse(c),this.startSelect(h,c.domEvent._clicks>1),c.preventDefault()},o.prototype.startSelect=function(c,l){c=c||this.editor.renderer.screenToTextCoordinates(this.x,this.y);var h=this.editor;this.mousedownEvent&&(this.mousedownEvent.getShiftKey()?h.selection.selectToPosition(c):l||h.selection.moveToPosition(c),l||this.select(),h.setStyle("ace_selecting"),this.setState("select"))},o.prototype.select=function(){var c,l=this.editor,h=l.renderer.screenToTextCoordinates(this.x,this.y);if(this.$clickSelection){var d=this.$clickSelection.comparePoint(h);if(d==-1)c=this.$clickSelection.end;else if(d==1)c=this.$clickSelection.start;else{var g=r(this.$clickSelection,h);h=g.cursor,c=g.anchor}l.selection.setSelectionAnchor(c.row,c.column)}l.selection.selectToPosition(h),l.renderer.scrollCursorIntoView()},o.prototype.extendSelectionBy=function(c){var l,h=this.editor,d=h.renderer.screenToTextCoordinates(this.x,this.y),g=h.selection[c](d.row,d.column);if(this.$clickSelection){var _=this.$clickSelection.comparePoint(g.start),v=this.$clickSelection.comparePoint(g.end);if(_==-1&&v<=0)l=this.$clickSelection.end,(g.end.row!=d.row||g.end.column!=d.column)&&(d=g.start);else if(v==1&&_>=0)l=this.$clickSelection.start,(g.start.row!=d.row||g.start.column!=d.column)&&(d=g.end);else if(_==-1&&v==1)d=g.end,l=g.start;else{var M=r(this.$clickSelection,d);d=M.cursor,l=M.anchor}h.selection.setSelectionAnchor(l.row,l.column)}h.selection.selectToPosition(d),h.renderer.scrollCursorIntoView()},o.prototype.selectByLinesEnd=function(){this.$clickSelection=null,this.editor.unsetStyle("ace_selecting")},o.prototype.focusWait=function(){var c=a(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y),l=Date.now();(c>P||l-this.mousedownEvent.time>this.$focusTimeout)&&this.startSelect(this.mousedownEvent.getDocumentPosition())},o.prototype.onDoubleClick=function(c){var l=c.getDocumentPosition(),h=this.editor,d=h.session,g=d.getBracketRange(l);g?(g.isEmpty()&&(g.start.column--,g.end.column++),this.setState("select")):(g=h.selection.getWordRange(l.row,l.column),this.setState("selectByWords")),this.$clickSelection=g,this.select()},o.prototype.onTripleClick=function(c){var l=c.getDocumentPosition(),h=this.editor;this.setState("selectByLines");var d=h.getSelectionRange();d.isMultiLine()&&d.contains(l.row,l.column)?(this.$clickSelection=h.selection.getLineRange(d.start.row),this.$clickSelection.end=h.selection.getLineRange(d.end.row).end):this.$clickSelection=h.selection.getLineRange(l.row),this.select()},o.prototype.onQuadClick=function(c){var l=this.editor;l.selectAll(),this.$clickSelection=l.getSelectionRange(),this.setState("selectAll")},o.prototype.onMouseWheel=function(c){if(!c.getAccelKey()){c.getShiftKey()&&c.wheelY&&!c.wheelX&&(c.wheelX=c.wheelY,c.wheelY=0);var l=this.editor;this.$lastScroll||(this.$lastScroll={t:0,vx:0,vy:0,allowed:0});var h=this.$lastScroll,d=c.domEvent.timeStamp,g=d-h.t,_=g?c.wheelX/g:h.vx,v=g?c.wheelY/g:h.vy;g=1&&l.renderer.isScrollableBy(c.wheelX*c.speed,0)&&(y=!0),M<=1&&l.renderer.isScrollableBy(0,c.wheelY*c.speed)&&(y=!0),y)h.allowed=d;else if(d-h.allowed=h.length&&(h=void 0),{value:h&&h[_++],done:!h}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")},C=s("./lib/dom"),f=s("./range").Range,a="ace_tooltip",r=function(){function h(d){this.isOpen=!1,this.$element=null,this.$parentNode=d}return h.prototype.$init=function(){return this.$element=C.createElement("div"),this.$element.className=a,this.$element.style.display="none",this.$parentNode.appendChild(this.$element),this.$element},h.prototype.getElement=function(){return this.$element||this.$init()},h.prototype.setText=function(d){this.getElement().textContent=d},h.prototype.setHtml=function(d){this.getElement().innerHTML=d},h.prototype.setPosition=function(d,g){this.getElement().style.left=d+"px",this.getElement().style.top=g+"px"},h.prototype.setClassName=function(d){C.addCssClass(this.getElement(),d)},h.prototype.setTheme=function(d){this.$element.className=a+" "+(d.isDark?"ace_dark ":"")+(d.cssClass||"")},h.prototype.show=function(d,g,_){d!=null&&this.setText(d),g!=null&&_!=null&&this.setPosition(g,_),this.isOpen||(this.getElement().style.display="block",this.isOpen=!0)},h.prototype.hide=function(){this.isOpen&&(this.getElement().style.display="none",this.getElement().className=a,this.isOpen=!1)},h.prototype.getHeight=function(){return this.getElement().offsetHeight},h.prototype.getWidth=function(){return this.getElement().offsetWidth},h.prototype.destroy=function(){this.isOpen=!1,this.$element&&this.$element.parentNode&&this.$element.parentNode.removeChild(this.$element)},h}(),o=function(){function h(){this.popups=[]}return h.prototype.addPopup=function(d){this.popups.push(d),this.updatePopups()},h.prototype.removePopup=function(d){var g=this.popups.indexOf(d);g!==-1&&(this.popups.splice(g,1),this.updatePopups())},h.prototype.updatePopups=function(){var d,g,_,v;this.popups.sort(function(S,F){return F.priority-S.priority});var M=[];try{for(var y=P(this.popups),I=y.next();!I.done;I=y.next()){var w=I.value,x=!0;try{for(var N=(_=void 0,P(M)),D=N.next();!D.done;D=N.next()){var R=D.value;if(this.doPopupsOverlap(R,w)){x=!1;break}}}catch(S){_={error:S}}finally{try{D&&!D.done&&(v=N.return)&&v.call(N)}finally{if(_)throw _.error}}x?M.push(w):w.hide()}}catch(S){d={error:S}}finally{try{I&&!I.done&&(g=y.return)&&g.call(y)}finally{if(d)throw d.error}}},h.prototype.doPopupsOverlap=function(d,g){var _=d.getElement().getBoundingClientRect(),v=g.getElement().getBoundingClientRect();return _.leftv.left&&_.topv.top},h}(),c=new o;p.popupManager=c,p.Tooltip=r;var l=function(h){B(d,h);function d(g){g===void 0&&(g=document.body);var _=h.call(this,g)||this;_.timeout=void 0,_.lastT=0,_.idleTime=350,_.lastEvent=void 0,_.onMouseOut=_.onMouseOut.bind(_),_.onMouseMove=_.onMouseMove.bind(_),_.waitForHover=_.waitForHover.bind(_),_.hide=_.hide.bind(_);var v=_.getElement();return v.style.whiteSpace="pre-wrap",v.style.pointerEvents="auto",v.addEventListener("mouseout",_.onMouseOut),v.tabIndex=-1,v.addEventListener("blur",function(){v.contains(document.activeElement)||this.hide()}.bind(_)),_}return d.prototype.addToEditor=function(g){g.on("mousemove",this.onMouseMove),g.on("mousedown",this.hide),g.renderer.getMouseEventTarget().addEventListener("mouseout",this.onMouseOut,!0)},d.prototype.removeFromEditor=function(g){g.off("mousemove",this.onMouseMove),g.off("mousedown",this.hide),g.renderer.getMouseEventTarget().removeEventListener("mouseout",this.onMouseOut,!0),this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},d.prototype.onMouseMove=function(g,_){this.lastEvent=g,this.lastT=Date.now();var v=_.$mouseHandler.isMousePressed;if(this.isOpen){var M=this.lastEvent&&this.lastEvent.getDocumentPosition();(!this.range||!this.range.contains(M.row,M.column)||v||this.isOutsideOfText(this.lastEvent))&&this.hide()}this.timeout||v||(this.lastEvent=g,this.timeout=setTimeout(this.waitForHover,this.idleTime))},d.prototype.waitForHover=function(){this.timeout&&clearTimeout(this.timeout);var g=Date.now()-this.lastT;if(this.idleTime-g>10){this.timeout=setTimeout(this.waitForHover,this.idleTime-g);return}this.timeout=null,this.lastEvent&&!this.isOutsideOfText(this.lastEvent)&&this.$gatherData(this.lastEvent,this.lastEvent.editor)},d.prototype.isOutsideOfText=function(g){var _=g.editor,v=g.getDocumentPosition(),M=_.session.getLine(v.row);if(v.column==M.length){var y=_.renderer.pixelToScreenCoordinates(g.clientX,g.clientY),I=_.session.documentToScreenPosition(v.row,v.column);if(I.column!=y.column||I.row!=y.row)return!0}return!1},d.prototype.setDataProvider=function(g){this.$gatherData=g},d.prototype.showForRange=function(g,_,v,M){if(!(M&&M!=this.lastEvent)&&!(this.isOpen&&document.activeElement==this.getElement())){var y=g.renderer;this.isOpen||(c.addPopup(this),this.$registerCloseEvents(),this.setTheme(y.theme)),this.isOpen=!0,this.addMarker(_,g.session),this.range=f.fromPoints(_.start,_.end);var I=this.getElement();I.innerHTML="",I.appendChild(v),I.style.display="block";var w=y.textToScreenCoordinates(_.start.row,_.start.column),x=g.getCursorPosition(),N=I.clientHeight,D=y.scroller.getBoundingClientRect(),R=!0;this.row>x.row?R=!0:this.rowD.bottom&&(R=!1),R?w.pageY+=y.lineHeight:w.pageY-=N,I.style.maxWidth=D.width-(w.pageX-D.left)+"px",this.setPosition(w.pageX,w.pageY)}},d.prototype.addMarker=function(g,_){this.marker&&this.$markerSession.removeMarker(this.marker),this.$markerSession=_,this.marker=_&&_.addMarker(g,"ace_highlight-marker","text")},d.prototype.hide=function(g){!g&&document.activeElement==this.getElement()||g&&g.target&&(g.type!="keydown"||g.ctrlKey||g.metaKey)&&this.$element.contains(g.target)||(this.lastEvent=null,this.timeout&&clearTimeout(this.timeout),this.timeout=null,this.addMarker(null),this.isOpen&&(this.$removeCloseEvents(),this.getElement().style.display="none",this.isOpen=!1,c.removePopup(this)))},d.prototype.$registerCloseEvents=function(){window.addEventListener("keydown",this.hide,!0),window.addEventListener("mousewheel",this.hide,!0),window.addEventListener("mousedown",this.hide,!0)},d.prototype.$removeCloseEvents=function(){window.removeEventListener("keydown",this.hide,!0),window.removeEventListener("mousewheel",this.hide,!0),window.removeEventListener("mousedown",this.hide,!0)},d.prototype.onMouseOut=function(g){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.lastEvent=null,this.isOpen&&(!g.relatedTarget||g.relatedTarget==this.getElement()||g&&g.currentTarget.contains(g.relatedTarget)||g.relatedTarget.classList.contains("ace_content")||this.hide())},d}(r);p.HoverTooltip=l}),ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/tooltip","ace/config"],function(s,p,m){var B=this&&this.__extends||function(){var l=function(h,d){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,_){g.__proto__=_}||function(g,_){for(var v in _)Object.prototype.hasOwnProperty.call(_,v)&&(g[v]=_[v])},l(h,d)};return function(h,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");l(h,d);function g(){this.constructor=h}h.prototype=d===null?Object.create(d):(g.prototype=d.prototype,new g)}}(),P=this&&this.__values||function(l){var h=typeof Symbol=="function"&&Symbol.iterator,d=h&&l[h],g=0;if(d)return d.call(l);if(l&&typeof l.length=="number")return{next:function(){return l&&g>=l.length&&(l=void 0),{value:l&&l[g++],done:!l}}};throw new TypeError(h?"Object is not iterable.":"Symbol.iterator is not defined.")},C=s("../lib/dom"),f=s("../lib/event"),a=s("../tooltip").Tooltip,r=s("../config").nls;function o(l){var h=l.editor,d=h.renderer.$gutterLayer,g=new c(h);l.editor.setDefaultHandler("guttermousedown",function(w){if(!(!h.isFocused()||w.getButton()!=0)){var x=d.getRegion(w);if(x!="foldWidgets"){var N=w.getDocumentPosition().row,D=h.session.selection;if(w.getShiftKey())D.selectTo(N,0);else{if(w.domEvent.detail==2)return h.selectAll(),w.preventDefault();l.$clickSelection=h.selection.getLineRange(N)}return l.setState("selectByLines"),l.captureMouse(w),w.preventDefault()}}});var _,v;function M(){var w=v.getDocumentPosition().row,x=h.session.getLength();if(w==x){var N=h.renderer.pixelToScreenCoordinates(0,v.y).row,D=v.$pos;if(N>h.session.documentToScreenRow(D.row,D.column))return y()}if(g.showTooltip(w),!!g.isOpen)if(h.on("mousewheel",y),l.$tooltipFollowsMouse)I(v);else{var R=d.$lines.cells[w].element.querySelector("[class*=ace_icon]"),S=R.getBoundingClientRect(),F=g.getElement().style;F.left=S.right+"px",F.top=S.bottom+"px"}}function y(){_&&(_=clearTimeout(_)),g.isOpen&&(g.hide(),h._signal("hideGutterTooltip",g),h.off("mousewheel",y))}function I(w){g.setPosition(w.x,w.y)}l.editor.setDefaultHandler("guttermousemove",function(w){var x=w.domEvent.target||w.domEvent.srcElement;if(C.hasCssClass(x,"ace_fold-widget"))return y();g.isOpen&&l.$tooltipFollowsMouse&&I(w),v=w,!_&&(_=setTimeout(function(){_=null,v&&!l.isMousePressed?M():y()},50))}),f.addListener(h.renderer.$gutter,"mouseout",function(w){v=null,!(!g.isOpen||_)&&(_=setTimeout(function(){_=null,y()},50))},h),h.on("changeSession",y),h.on("input",y)}p.GutterHandler=o;var c=function(l){B(h,l);function h(d){var g=l.call(this,d.container)||this;return g.editor=d,g}return h.prototype.setPosition=function(d,g){var _=window.innerWidth||document.documentElement.clientWidth,v=window.innerHeight||document.documentElement.clientHeight,M=this.getWidth(),y=this.getHeight();d+=15,g+=15,d+M>_&&(d-=d+M-_),g+y>v&&(g-=20+y),a.prototype.setPosition.call(this,d,g)},Object.defineProperty(h,"annotationLabels",{get:function(){return{error:{singular:r("error"),plural:r("errors")},warning:{singular:r("warning"),plural:r("warnings")},info:{singular:r("information message"),plural:r("information messages")}}},enumerable:!1,configurable:!0}),h.prototype.showTooltip=function(d){var g=this.editor.renderer.$gutterLayer,_=g.$annotations[d],v;_?v={text:Array.from(_.text),type:Array.from(_.type)}:v={text:[],type:[]};var M=g.session.getFoldLine(d);if(M&&g.$showFoldedAnnotations){for(var y={error:[],warning:[],info:[]},I,w=d+1;w<=M.end.row;w++)if(g.$annotations[w])for(var x=0;x ").concat(v.text[w]);R[v.type[w].replace("_fold","")].push(F)}var A=[].concat(R.error,R.warning,R.info).join("
");this.setHtml(A),this.setClassName("ace_gutter-tooltip"),this.$element.setAttribute("aria-live","polite"),this.isOpen||this.setTheme(this.editor.renderer.theme),this.editor._signal("showGutterTooltip",this),this.show()},h.annotationsToSummaryString=function(d){var g,_,v=[],M=["error","warning","info"];try{for(var y=P(M),I=y.next();!I.done;I=y.next()){var w=I.value;if(d[w].length){var x=d[w].length===1?h.annotationLabels[w].singular:h.annotationLabels[w].plural;v.push("".concat(d[w].length," ").concat(x))}}}catch(N){g={error:N}}finally{try{I&&!I.done&&(_=y.return)&&_.call(y)}finally{if(g)throw g.error}}return v.join(", ")},h}(a);p.GutterTooltip=c}),ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"],function(s,p,m){var B=s("../lib/event"),P=s("../lib/useragent"),C=function(){function f(a,r){this.domEvent=a,this.editor=r,this.x=this.clientX=a.clientX,this.y=this.clientY=a.clientY,this.$pos=null,this.$inSelection=null,this.propagationStopped=!1,this.defaultPrevented=!1}return f.prototype.stopPropagation=function(){B.stopPropagation(this.domEvent),this.propagationStopped=!0},f.prototype.preventDefault=function(){B.preventDefault(this.domEvent),this.defaultPrevented=!0},f.prototype.stop=function(){this.stopPropagation(),this.preventDefault()},f.prototype.getDocumentPosition=function(){return this.$pos?this.$pos:(this.$pos=this.editor.renderer.screenToTextCoordinates(this.clientX,this.clientY),this.$pos)},f.prototype.inSelection=function(){if(this.$inSelection!==null)return this.$inSelection;var a=this.editor,r=a.getSelectionRange();if(r.isEmpty())this.$inSelection=!1;else{var o=this.getDocumentPosition();this.$inSelection=r.contains(o.row,o.column)}return this.$inSelection},f.prototype.getButton=function(){return B.getButton(this.domEvent)},f.prototype.getShiftKey=function(){return this.domEvent.shiftKey},f.prototype.getAccelKey=function(){return P.isMac?this.domEvent.metaKey:this.domEvent.ctrlKey},f}();p.MouseEvent=C}),ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"],function(s,p,m){var B=s("../lib/dom"),P=s("../lib/event"),C=s("../lib/useragent"),f=200,a=200,r=5;function o(l){var h=l.editor,d=B.createElement("div");d.style.cssText="top:-100px;position:absolute;z-index:2147483647;opacity:0.5",d.textContent=" ";var g=["dragWait","dragWaitEnd","startDrag","dragReadyEnd","onMouseDrag"];g.forEach(function(J){l[J]=this[J]},this),h.on("mousedown",this.onMouseDown.bind(l));var _=h.container,v,M,y,I,w,x,N=0,D,R,S,F,A;this.onDragStart=function(J){if(this.cancelDrag||!_.draggable){var Y=this;return setTimeout(function(){Y.startSelect(),Y.captureMouse(J)},0),J.preventDefault()}w=h.getSelectionRange();var z=J.dataTransfer;z.effectAllowed=h.getReadOnly()?"copy":"copyMove",h.container.appendChild(d),z.setDragImage&&z.setDragImage(d,0,0),setTimeout(function(){h.container.removeChild(d)}),z.clearData(),z.setData("Text",h.session.getTextRange()),R=!0,this.setState("drag")},this.onDragEnd=function(J){if(_.draggable=!1,R=!1,this.setState(null),!h.getReadOnly()){var Y=J.dataTransfer.dropEffect;!D&&Y=="move"&&h.session.remove(h.getSelectionRange()),h.$resetCursorStyle()}this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle("")},this.onDragEnter=function(J){if(!(h.getReadOnly()||!Q(J.dataTransfer)))return M=J.clientX,y=J.clientY,v||H(),N++,J.dataTransfer.dropEffect=D=ie(J),P.preventDefault(J)},this.onDragOver=function(J){if(!(h.getReadOnly()||!Q(J.dataTransfer)))return M=J.clientX,y=J.clientY,v||(H(),N++),W!==null&&(W=null),J.dataTransfer.dropEffect=D=ie(J),P.preventDefault(J)},this.onDragLeave=function(J){if(N--,N<=0&&v)return V(),D=null,P.preventDefault(J)},this.onDrop=function(J){if(x){var Y=J.dataTransfer;if(R)switch(D){case"move":w.contains(x.row,x.column)?w={start:x,end:x}:w=h.moveText(w,x);break;case"copy":w=h.moveText(w,x,!0);break}else{var z=Y.getData("Text");w={start:x,end:h.session.insert(x,z)},h.focus(),D=null}return V(),P.preventDefault(J)}},P.addListener(_,"dragstart",this.onDragStart.bind(l),h),P.addListener(_,"dragend",this.onDragEnd.bind(l),h),P.addListener(_,"dragenter",this.onDragEnter.bind(l),h),P.addListener(_,"dragover",this.onDragOver.bind(l),h),P.addListener(_,"dragleave",this.onDragLeave.bind(l),h),P.addListener(_,"drop",this.onDrop.bind(l),h);function E(J,Y){var z=Date.now(),oe=!Y||J.row!=Y.row,he=!Y||J.column!=Y.column;if(!F||oe||he)h.moveCursorToPosition(J),F=z,A={x:M,y};else{var de=c(A.x,A.y,M,y);de>r?F=null:z-F>=a&&(h.renderer.scrollCursorIntoView(),F=null)}}function O(J,Y){var z=Date.now(),oe=h.renderer.layerConfig.lineHeight,he=h.renderer.layerConfig.characterWidth,de=h.renderer.scroller.getBoundingClientRect(),fe={x:{left:M-de.left,right:de.right-M},y:{top:y-de.top,bottom:de.bottom-y}},le=Math.min(fe.x.left,fe.x.right),Re=Math.min(fe.y.top,fe.y.bottom),je={row:J.row,column:J.column};le/he<=2&&(je.column+=fe.x.left=f&&h.renderer.scrollCursorIntoView(je):S=z:S=null}function k(){var J=x;x=h.renderer.screenToTextCoordinates(M,y),E(x,J),O(x,J)}function H(){w=h.selection.toOrientedRange(),v=h.session.addMarker(w,"ace_selection",h.getSelectionStyle()),h.clearSelection(),h.isFocused()&&h.renderer.$cursorLayer.setBlinking(!1),clearInterval(I),k(),I=setInterval(k,20),N=0,P.addListener(document,"mousemove",K)}function V(){clearInterval(I),h.session.removeMarker(v),v=null,h.selection.fromOrientedRange(w),h.isFocused()&&!R&&h.$resetCursorStyle(),w=null,x=null,N=0,S=null,F=null,P.removeListener(document,"mousemove",K)}var W=null;function K(){W==null&&(W=setTimeout(function(){W!=null&&v&&V()},20))}function Q(J){var Y=J.types;return!Y||Array.prototype.some.call(Y,function(z){return z=="text/plain"||z=="Text"})}function ie(J){var Y=["copy","copymove","all","uninitialized"],z=["move","copymove","linkmove","all","uninitialized"],oe=C.isMac?J.altKey:J.ctrlKey,he="uninitialized";try{he=J.dataTransfer.effectAllowed.toLowerCase()}catch{}var de="none";return oe&&Y.indexOf(he)>=0?de="copy":z.indexOf(he)>=0?de="move":Y.indexOf(he)>=0&&(de="copy"),de}}(function(){this.dragWait=function(){var l=Date.now()-this.mousedownEvent.time;l>this.editor.getDragDelay()&&this.startDrag()},this.dragWaitEnd=function(){var l=this.editor.container;l.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()),this.selectEnd()},this.dragReadyEnd=function(l){this.editor.$resetCursorStyle(),this.editor.unsetStyle("ace_dragging"),this.editor.renderer.setCursorStyle(""),this.dragWaitEnd()},this.startDrag=function(){this.cancelDrag=!1;var l=this.editor,h=l.container;h.draggable=!0,l.renderer.$cursorLayer.setBlinking(!1),l.setStyle("ace_dragging");var d=C.isWin?"default":"move";l.renderer.setCursorStyle(d),this.setState("dragReady")},this.onMouseDrag=function(l){var h=this.editor.container;if(C.isIE&&this.state=="dragReady"){var d=c(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);d>3&&h.dragDrop()}if(this.state==="dragWait"){var d=c(this.mousedownEvent.x,this.mousedownEvent.y,this.x,this.y);d>0&&(h.draggable=!1,this.startSelect(this.mousedownEvent.getDocumentPosition()))}},this.onMouseDown=function(l){if(this.$dragEnabled){this.mousedownEvent=l;var h=this.editor,d=l.inSelection(),g=l.getButton(),_=l.domEvent.detail||1;if(_===1&&g===0&&d){if(l.editor.inMultiSelectMode&&(l.getAccelKey()||l.getShiftKey()))return;this.mousedownEvent.time=Date.now();var v=l.domEvent.target||l.domEvent.srcElement;if("unselectable"in v&&(v.unselectable="on"),h.getDragDelay()){if(C.isWebKit){this.cancelDrag=!0;var M=h.container;M.draggable=!0}this.setState("dragWait")}else this.startDrag();this.captureMouse(l,this.onMouseDrag.bind(this)),l.defaultPrevented=!0}}}}).call(o.prototype);function c(l,h,d,g){return Math.sqrt(Math.pow(d-l,2)+Math.pow(g-h,2))}p.DragdropHandler=o}),ace.define("ace/mouse/touch_handler",["require","exports","module","ace/mouse/mouse_event","ace/lib/event","ace/lib/dom"],function(s,p,m){var B=s("./mouse_event").MouseEvent,P=s("../lib/event"),C=s("../lib/dom");p.addTouchListeners=function(f,a){var r="scroll",o,c,l,h,d,g,_=0,v,M=0,y=0,I=0,w,x;function N(){var E=window.navigator&&window.navigator.clipboard,O=!1,k=function(){var V=a.getCopyText(),W=a.session.getUndoManager().hasUndo();x.replaceChild(C.buildDom(O?["span",!V&&["span",{class:"ace_mobile-button",action:"selectall"},"Select All"],V&&["span",{class:"ace_mobile-button",action:"copy"},"Copy"],V&&["span",{class:"ace_mobile-button",action:"cut"},"Cut"],E&&["span",{class:"ace_mobile-button",action:"paste"},"Paste"],W&&["span",{class:"ace_mobile-button",action:"undo"},"Undo"],["span",{class:"ace_mobile-button",action:"find"},"Find"],["span",{class:"ace_mobile-button",action:"openCommandPallete"},"Palette"]]:["span"]),x.firstChild)},H=function(V){var W=V.target.getAttribute("action");if(W=="more"||!O)return O=!O,k();W=="paste"?E.readText().then(function(K){a.execCommand(W,K)}):W&&((W=="cut"||W=="copy")&&(E?E.writeText(a.getCopyText()):document.execCommand("copy")),a.execCommand(W)),x.firstChild.style.display="none",O=!1,W!="openCommandPallete"&&a.focus()};x=C.buildDom(["div",{class:"ace_mobile-menu",ontouchstart:function(V){r="menu",V.stopPropagation(),V.preventDefault(),a.textInput.focus()},ontouchend:function(V){V.stopPropagation(),V.preventDefault(),H(V)},onclick:H},["span"],["span",{class:"ace_mobile-button",action:"more"},"..."]],a.container)}function D(){x||N();var E=a.selection.cursor,O=a.renderer.textToScreenCoordinates(E.row,E.column),k=a.renderer.textToScreenCoordinates(0,0).pageX,H=a.renderer.scrollLeft,V=a.container.getBoundingClientRect();x.style.top=O.pageY-V.top-3+"px",O.pageX-V.left=2?a.selection.getLineRange(v.row):a.session.getBracketRange(v);E&&!E.isEmpty()?a.selection.setRange(E):a.selection.selectWord(),r="wait"}P.addListener(f,"contextmenu",function(E){if(w){var O=a.textInput.getElement();O.focus()}},a),P.addListener(f,"touchstart",function(E){var O=E.touches;if(d||O.length>1){clearTimeout(d),d=null,l=-1,r="zoom";return}w=a.$mouseHandler.isMousePressed=!0;var k=a.renderer.layerConfig.lineHeight,H=a.renderer.layerConfig.lineHeight,V=E.timeStamp;h=V;var W=O[0],K=W.clientX,Q=W.clientY;Math.abs(o-K)+Math.abs(c-Q)>k&&(l=-1),o=E.clientX=K,c=E.clientY=Q,y=I=0;var ie=new B(E,a);if(v=ie.getDocumentPosition(),V-l<500&&O.length==1&&!_)M++,E.preventDefault(),E.button=0,F();else{M=0;var J=a.selection.cursor,Y=a.selection.isEmpty()?J:a.selection.anchor,z=a.renderer.$cursorLayer.getPixelPosition(J,!0),oe=a.renderer.$cursorLayer.getPixelPosition(Y,!0),he=a.renderer.scroller.getBoundingClientRect(),de=a.renderer.layerConfig.offset,fe=a.renderer.scrollLeft,le=function(vt,nt){return vt=vt/H,nt=nt/k-.75,vt*vt+nt*nt};if(E.clientXje?"cursor":"anchor"),je<3.5?r="anchor":Re<3.5?r="cursor":r="scroll",d=setTimeout(S,450)}l=V},a),P.addListener(f,"touchend",function(E){w=a.$mouseHandler.isMousePressed=!1,g&&clearInterval(g),r=="zoom"?(r="",_=0):d?(a.selection.moveToPosition(v),_=0,D()):r=="scroll"?(A(),R()):D(),clearTimeout(d),d=null},a),P.addListener(f,"touchmove",function(E){d&&(clearTimeout(d),d=null);var O=E.touches;if(!(O.length>1||r=="zoom")){var k=O[0],H=o-k.clientX,V=c-k.clientY;if(r=="wait")if(H*H+V*V>4)r="cursor";else return E.preventDefault();o=k.clientX,c=k.clientY,E.clientX=k.clientX,E.clientY=k.clientY;var W=E.timeStamp,K=W-h;if(h=W,r=="scroll"){var Q=new B(E,a);Q.speed=1,Q.wheelX=H,Q.wheelY=V,10*Math.abs(H)0)if(je==16){for(Ue=nt;Ue-1){for(Ue=nt;Ue=0&&oe[Ct]==w;Ct--)Y[Ct]=B}}}function K(J,Y,z){if(!(P=J){for(de=he+1;de=J;)de++;for(fe=he,le=de-1;fe=Y.length||(de=z[oe-1])!=g&&de!=_||(fe=Y[oe+1])!=g&&fe!=_?v:(C&&(fe=_),fe==de?fe:v);case N:return de=oe>0?z[oe-1]:M,de==g&&oe+10&&z[oe-1]==g)return g;if(C)return v;for(Re=oe+1,le=Y.length;Re=1425&&je<=2303||je==64286;if(de=Y[Re],vt&&(de==d||de==I))return d}return oe<1||(de=Y[oe-1])==M?v:z[oe-1];case M:return C=!1,f=!0,B;case y:return a=!0,v;case S:case F:case E:case O:case A:C=!1;case k:return v}}function ie(J){var Y=J.charCodeAt(0),z=Y>>8;return z==0?Y>191?h:H[Y]:z==5?/[\u0591-\u05f4]/.test(J)?d:h:z==6?/[\u0610-\u061a\u064b-\u065f\u06d6-\u06e4\u06e7-\u06ed]/.test(J)?R:/[\u0660-\u0669\u066b-\u066c]/.test(J)?_:Y==1642?D:/[\u06f0-\u06f9]/.test(J)?g:I:z==32&&Y<=8287?V[Y&255]:z==254&&Y>=65136?I:v}p.L=h,p.R=d,p.EN=g,p.ON_R=3,p.AN=4,p.R_H=5,p.B=6,p.RLE=7,p.DOT="·",p.doBidiReorder=function(J,Y,z){if(J.length<2)return{};var oe=J.split(""),he=new Array(oe.length),de=new Array(oe.length),fe=[];B=z?l:c,W(oe,fe,oe.length,Y);for(var le=0;leI&&Y[le]0&&oe[le-1]==="ل"&&/\u0622|\u0623|\u0625|\u0627/.test(oe[le])&&(fe[le-1]=fe[le]=p.R_H,le++);oe[oe.length-1]===p.DOT&&(fe[oe.length-1]=p.B),oe[0]==="‫"&&(fe[0]=p.RLE);for(var le=0;le=0&&(r=this.session.$docRowCache[c])}return r},a.prototype.getSplitIndex=function(){var r=0,o=this.session.$screenRowCache;if(o.length)for(var c,l=this.session.$getRowCacheIndex(o,this.currentRow);this.currentRow-r>0&&(c=this.session.$getRowCacheIndex(o,this.currentRow-r-1),c===l);)l=c,r++;else r=this.currentRow;return r},a.prototype.updateRowLine=function(r,o){r===void 0&&(r=this.getDocumentRow());var c=r===this.session.getLength()-1,l=c?this.EOF:this.EOL;if(this.wrapIndent=0,this.line=this.session.getLine(r),this.isRtlDir=this.$isRtl||this.line.charAt(0)===this.RLE,this.session.$useWrapMode){var h=this.session.$wrapData[r];h&&(o===void 0&&(o=this.getSplitIndex()),o>0&&h.length?(this.wrapIndent=h.indent,this.wrapOffset=this.wrapIndent*this.charWidths[B.L],this.line=oo?this.session.getOverwrite()?r:r-1:o,l=B.getVisualFromLogicalIdx(c,this.bidiMap),h=this.bidiMap.bidiLevels,d=0;!this.session.getOverwrite()&&r<=o&&h[l]%2!==0&&l++;for(var g=0;go&&h[l]%2===0&&(d+=this.charWidths[h[l]]),this.wrapIndent&&(d+=this.isRtlDir?-1*this.wrapOffset:this.wrapOffset),this.isRtlDir&&(d+=this.rtlLineOffset),d},a.prototype.getSelections=function(r,o){var c=this.bidiMap,l=c.bidiLevels,h,d=[],g=0,_=Math.min(r,o)-this.wrapIndent,v=Math.max(r,o)-this.wrapIndent,M=!1,y=!1,I=0;this.wrapIndent&&(g+=this.isRtlDir?-1*this.wrapOffset:this.wrapOffset);for(var w,x=0;x=_&&wl+g/2;){if(l+=g,h===d.length-1){g=0;break}g=this.charWidths[d[++h]]}return h>0&&d[h-1]%2!==0&&d[h]%2===0?(c0&&d[h-1]%2===0&&d[h]%2!==0?o=1+(c>l?this.bidiMap.logicalFromVisual[h]:this.bidiMap.logicalFromVisual[h-1]):this.isRtlDir&&h===d.length-1&&g===0&&d[h-1]%2===0||!this.isRtlDir&&h===0&&d[h]%2!==0?o=1+this.bidiMap.logicalFromVisual[h]:(h>0&&d[h-1]%2!==0&&g!==0&&h--,o=this.bidiMap.logicalFromVisual[h]),o===0&&this.isRtlDir&&o++,o+this.wrapIndent},a}();p.BidiHandler=f}),ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"],function(s,p,m){var B=s("./lib/oop"),P=s("./lib/lang"),C=s("./lib/event_emitter").EventEmitter,f=s("./range").Range,a=function(r){this.session=r,this.doc=r.getDocument(),this.clearSelection(),this.cursor=this.lead=this.doc.createAnchor(0,0),this.anchor=this.doc.createAnchor(0,0),this.$silent=!1;var o=this;this.cursor.on("change",function(c){o.$cursorChanged=!0,o.$silent||o._emit("changeCursor"),!o.$isEmpty&&!o.$silent&&o._emit("changeSelection"),!o.$keepDesiredColumnOnChange&&c.old.column!=c.value.column&&(o.$desiredColumn=null)}),this.anchor.on("change",function(){o.$anchorChanged=!0,!o.$isEmpty&&!o.$silent&&o._emit("changeSelection")})};(function(){B.implement(this,C),this.isEmpty=function(){return this.$isEmpty||this.anchor.row==this.lead.row&&this.anchor.column==this.lead.column},this.isMultiLine=function(){return!this.$isEmpty&&this.anchor.row!=this.cursor.row},this.getCursor=function(){return this.lead.getPosition()},this.setAnchor=function(r,o){this.$isEmpty=!1,this.anchor.setPosition(r,o)},this.setSelectionAnchor=this.setAnchor,this.getAnchor=function(){return this.$isEmpty?this.getSelectionLead():this.anchor.getPosition()},this.getSelectionAnchor=this.getAnchor,this.getSelectionLead=function(){return this.lead.getPosition()},this.isBackwards=function(){var r=this.anchor,o=this.lead;return r.row>o.row||r.row==o.row&&r.column>o.column},this.getRange=function(){var r=this.anchor,o=this.lead;return this.$isEmpty?f.fromPoints(o,o):this.isBackwards()?f.fromPoints(o,r):f.fromPoints(r,o)},this.clearSelection=function(){this.$isEmpty||(this.$isEmpty=!0,this._emit("changeSelection"))},this.selectAll=function(){this.$setSelection(0,0,Number.MAX_VALUE,Number.MAX_VALUE)},this.setRange=this.setSelectionRange=function(r,o){var c=o?r.end:r.start,l=o?r.start:r.end;this.$setSelection(c.row,c.column,l.row,l.column)},this.$setSelection=function(r,o,c,l){if(!this.$silent){var h=this.$isEmpty,d=this.inMultiSelectMode;this.$silent=!0,this.$cursorChanged=this.$anchorChanged=!1,this.anchor.setPosition(r,o),this.cursor.setPosition(c,l),this.$isEmpty=!f.comparePoints(this.anchor,this.cursor),this.$silent=!1,this.$cursorChanged&&this._emit("changeCursor"),(this.$cursorChanged||this.$anchorChanged||h!=this.$isEmpty||d)&&this._emit("changeSelection")}},this.$moveSelection=function(r){var o=this.lead;this.$isEmpty&&this.setSelectionAnchor(o.row,o.column),r.call(this)},this.selectTo=function(r,o){this.$moveSelection(function(){this.moveCursorTo(r,o)})},this.selectToPosition=function(r){this.$moveSelection(function(){this.moveCursorToPosition(r)})},this.moveTo=function(r,o){this.clearSelection(),this.moveCursorTo(r,o)},this.moveToPosition=function(r){this.clearSelection(),this.moveCursorToPosition(r)},this.selectUp=function(){this.$moveSelection(this.moveCursorUp)},this.selectDown=function(){this.$moveSelection(this.moveCursorDown)},this.selectRight=function(){this.$moveSelection(this.moveCursorRight)},this.selectLeft=function(){this.$moveSelection(this.moveCursorLeft)},this.selectLineStart=function(){this.$moveSelection(this.moveCursorLineStart)},this.selectLineEnd=function(){this.$moveSelection(this.moveCursorLineEnd)},this.selectFileEnd=function(){this.$moveSelection(this.moveCursorFileEnd)},this.selectFileStart=function(){this.$moveSelection(this.moveCursorFileStart)},this.selectWordRight=function(){this.$moveSelection(this.moveCursorWordRight)},this.selectWordLeft=function(){this.$moveSelection(this.moveCursorWordLeft)},this.getWordRange=function(r,o){if(typeof o>"u"){var c=r||this.lead;r=c.row,o=c.column}return this.session.getWordRange(r,o)},this.selectWord=function(){this.setSelectionRange(this.getWordRange())},this.selectAWord=function(){var r=this.getCursor(),o=this.session.getAWordRange(r.row,r.column);this.setSelectionRange(o)},this.getLineRange=function(r,o){var c=typeof r=="number"?r:this.lead.row,l,h=this.session.getFoldLine(c);return h?(c=h.start.row,l=h.end.row):l=c,o===!0?new f(c,0,l,this.session.getLine(l).length):new f(c,0,l+1,0)},this.selectLine=function(){this.setSelectionRange(this.getLineRange())},this.moveCursorUp=function(){this.moveCursorBy(-1,0)},this.moveCursorDown=function(){this.moveCursorBy(1,0)},this.wouldMoveIntoSoftTab=function(r,o,c){var l=r.column,h=r.column+o;return c<0&&(l=r.column-o,h=r.column),this.session.isTabStop(r)&&this.doc.getLine(r.row).slice(l,h).split(" ").length-1==o},this.moveCursorLeft=function(){var r=this.lead.getPosition(),o;if(o=this.session.getFoldAt(r.row,r.column,-1))this.moveCursorTo(o.start.row,o.start.column);else if(r.column===0)r.row>0&&this.moveCursorTo(r.row-1,this.doc.getLine(r.row-1).length);else{var c=this.session.getTabSize();this.wouldMoveIntoSoftTab(r,c,-1)&&!this.session.getNavigateWithinSoftTabs()?this.moveCursorBy(0,-c):this.moveCursorBy(0,-1)}},this.moveCursorRight=function(){var r=this.lead.getPosition(),o;if(o=this.session.getFoldAt(r.row,r.column,1))this.moveCursorTo(o.end.row,o.end.column);else if(this.lead.column==this.doc.getLine(this.lead.row).length)this.lead.row0&&(o.column=l)}}this.moveCursorTo(o.row,o.column)},this.moveCursorFileEnd=function(){var r=this.doc.getLength()-1,o=this.doc.getLine(r).length;this.moveCursorTo(r,o)},this.moveCursorFileStart=function(){this.moveCursorTo(0,0)},this.moveCursorLongWordRight=function(){var r=this.lead.row,o=this.lead.column,c=this.doc.getLine(r),l=c.substring(o);this.session.nonTokenRe.lastIndex=0,this.session.tokenRe.lastIndex=0;var h=this.session.getFoldAt(r,o,1);if(h){this.moveCursorTo(h.end.row,h.end.column);return}if(this.session.nonTokenRe.exec(l)&&(o+=this.session.nonTokenRe.lastIndex,this.session.nonTokenRe.lastIndex=0,l=c.substring(o)),o>=c.length){this.moveCursorTo(r,c.length),this.moveCursorRight(),r0&&this.moveCursorWordLeft();return}this.session.tokenRe.exec(h)&&(o-=this.session.tokenRe.lastIndex,this.session.tokenRe.lastIndex=0),this.moveCursorTo(r,o)},this.$shortWordEndIndex=function(r){var o=0,c,l=/\s/,h=this.session.tokenRe;if(h.lastIndex=0,this.session.tokenRe.exec(r))o=this.session.tokenRe.lastIndex;else{for(;(c=r[o])&&l.test(c);)o++;if(o<1){for(h.lastIndex=0;(c=r[o])&&!h.test(c);)if(h.lastIndex=0,o++,l.test(c))if(o>2){o--;break}else{for(;(c=r[o])&&l.test(c);)o++;if(o>2)break}}}return h.lastIndex=0,o},this.moveCursorShortWordRight=function(){var r=this.lead.row,o=this.lead.column,c=this.doc.getLine(r),l=c.substring(o),h=this.session.getFoldAt(r,o,1);if(h)return this.moveCursorTo(h.end.row,h.end.column);if(o==c.length){var d=this.doc.getLength();do r++,l=this.doc.getLine(r);while(r0&&/^\s*$/.test(l));o=l.length,/\s+$/.test(l)||(l="")}var h=P.stringReverse(l),d=this.$shortWordEndIndex(h);return this.moveCursorTo(r,o-d)},this.moveCursorWordRight=function(){this.session.$selectLongWords?this.moveCursorLongWordRight():this.moveCursorShortWordRight()},this.moveCursorWordLeft=function(){this.session.$selectLongWords?this.moveCursorLongWordLeft():this.moveCursorShortWordLeft()},this.moveCursorBy=function(r,o){var c=this.session.documentToScreenPosition(this.lead.row,this.lead.column),l;if(o===0&&(r!==0&&(this.session.$bidiHandler.isBidiRow(c.row,this.lead.row)?(l=this.session.$bidiHandler.getPosLeft(c.column),c.column=Math.round(l/this.session.$bidiHandler.charWidths[0])):l=c.column*this.session.$bidiHandler.charWidths[0]),this.$desiredColumn?c.column=this.$desiredColumn:this.$desiredColumn=c.column),r!=0&&this.session.lineWidgets&&this.session.lineWidgets[this.lead.row]){var h=this.session.lineWidgets[this.lead.row];r<0?r-=h.rowsAbove||0:r>0&&(r+=h.rowCount-(h.rowsAbove||0))}var d=this.session.screenToDocumentPosition(c.row+r,c.column,l);r!==0&&o===0&&d.row===this.lead.row&&(d.column,this.lead.column),this.moveCursorTo(d.row,d.column+o,o===0)},this.moveCursorToPosition=function(r){this.moveCursorTo(r.row,r.column)},this.moveCursorTo=function(r,o,c){var l=this.session.getFoldAt(r,o,1);l&&(r=l.start.row,o=l.start.column),this.$keepDesiredColumnOnChange=!0;var h=this.session.getLine(r);/[\uDC00-\uDFFF]/.test(h.charAt(o))&&h.charAt(o-1)&&(this.lead.row==r&&this.lead.column==o+1?o=o-1:o=o+1),this.lead.setPosition(r,o),this.$keepDesiredColumnOnChange=!1,c||(this.$desiredColumn=null)},this.moveCursorToScreen=function(r,o,c){var l=this.session.screenToDocumentPosition(r,o);this.moveCursorTo(l.row,l.column,c)},this.detach=function(){this.lead.detach(),this.anchor.detach()},this.fromOrientedRange=function(r){this.setSelectionRange(r,r.cursor==r.start),this.$desiredColumn=r.desiredColumn||this.$desiredColumn},this.toOrientedRange=function(r){var o=this.getRange();return r?(r.start.column=o.start.column,r.start.row=o.start.row,r.end.column=o.end.column,r.end.row=o.end.row):r=o,r.cursor=this.isBackwards()?r.start:r.end,r.desiredColumn=this.$desiredColumn,r},this.getRangeOfMovements=function(r){var o=this.getCursor();try{r(this);var c=this.getCursor();return f.fromPoints(o,c)}catch{return f.fromPoints(o,o)}finally{this.moveCursorToPosition(o)}},this.toJSON=function(){if(this.rangeCount)var r=this.ranges.map(function(o){var c=o.clone();return c.isBackwards=o.cursor==o.start,c});else{var r=this.getRange();r.isBackwards=this.isBackwards()}return r},this.fromJSON=function(r){if(r.start==null)if(this.rangeList&&r.length>1){this.toSingleRange(r[0]);for(var o=r.length;o--;){var c=f.fromPoints(r[o].start,r[o].end);r[o].isBackwards&&(c.cursor=c.start),this.addRange(c,!0)}return}else r=r[0];this.rangeList&&this.toSingleRange(r),this.setSelectionRange(r,r.isBackwards)},this.isEqual=function(r){if((r.length||this.rangeCount)&&r.length!=this.rangeCount)return!1;if(!r.length||!this.ranges)return this.getRange().isEqual(r);for(var o=this.ranges.length;o--;)if(!this.ranges[o].isEqual(r[o]))return!1;return!0}}).call(a.prototype),p.Selection=a}),ace.define("ace/tokenizer",["require","exports","module","ace/config"],function(s,p,m){var B=s("./config"),P=2e3,C=function(){function f(a){this.states=a,this.regExps={},this.matchMappings={};for(var r in this.states){for(var o=this.states[r],c=[],l=0,h=this.matchMappings[r]={defaultToken:"text"},d="g",g=[],_=0;_1?v.onMatch=this.$applyToken:v.onMatch=v.token),y>1&&(/\\\d/.test(v.regex)?M=v.regex.replace(/\\([0-9]+)/g,function(I,w){return"\\"+(parseInt(w,10)+l+1)}):(y=1,M=this.removeCapturingGroups(v.regex)),!v.splitRegex&&typeof v.token!="string"&&g.push(v)),h[l]=_,l+=y,c.push(M),v.onMatch||(v.onMatch=null)}}c.length||(h[0]=0,c.push("$")),g.forEach(function(I){I.splitRegex=this.createSplitterRegexp(I.regex,d)},this),this.regExps[r]=new RegExp("("+c.join(")|(")+")|($)",d)}}return f.prototype.$setMaxTokenCount=function(a){P=a|0},f.prototype.$applyToken=function(a){var r=this.splitRegex.exec(a).slice(1),o=this.token.apply(this,r);if(typeof o=="string")return[{type:o,value:a}];for(var c=[],l=0,h=o.length;lv){var D=a.substring(v,N-x.length);y.type==I?y.value+=D:(y.type&&_.push(y),y={type:I,value:D})}for(var R=0;RP){for(M>2*a.length&&this.reportError("infinite loop with in ace tokenizer",{startState:r,line:a});v1&&o[0]!==c&&o.unshift("#tmp",c),{tokens:_,state:o.length?o:c}},f}();C.prototype.reportError=B.reportError,p.Tokenizer=C}),ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"],function(s,p,m){var B=s("../lib/lang"),P=function(){this.$rules={start:[{token:"empty_line",regex:"^$"},{defaultToken:"text"}]}};(function(){this.addRules=function(a,r){if(!r){for(var o in a)this.$rules[o]=a[o];return}for(var o in a){for(var c=a[o],l=0;l=this.$rowTokens.length;){if(this.$row+=1,f||(f=this.$session.getLength()),this.$row>=f)return this.$row=f-1,null;this.$rowTokens=this.$session.getTokens(this.$row),this.$tokenIndex=0}return this.$rowTokens[this.$tokenIndex]},C.prototype.getCurrentToken=function(){return this.$rowTokens[this.$tokenIndex]},C.prototype.getCurrentTokenRow=function(){return this.$row},C.prototype.getCurrentTokenColumn=function(){var f=this.$rowTokens,a=this.$tokenIndex,r=f[a].start;if(r!==void 0)return r;for(r=0;a>0;)a-=1,r+=f[a].value.length;return r},C.prototype.getCurrentTokenPosition=function(){return{row:this.$row,column:this.getCurrentTokenColumn()}},C.prototype.getCurrentTokenRange=function(){var f=this.$rowTokens[this.$tokenIndex],a=this.getCurrentTokenColumn();return new B(this.$row,a,this.$row,a+f.value.length)},C}();p.TokenIterator=P}),ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],function(s,p,m){var B=s("../../lib/oop"),P=s("../behaviour").Behaviour,C=s("../../token_iterator").TokenIterator,f=s("../../lib/lang"),a=["text","paren.rparen","rparen","paren","punctuation.operator"],r=["text","paren.rparen","rparen","paren","punctuation.operator","comment"],o,c={},l={'"':'"',"'":"'"},h=function(_){var v=-1;if(_.multiSelect&&(v=_.selection.index,c.rangeCount!=_.multiSelect.rangeCount&&(c={rangeCount:_.multiSelect.rangeCount})),c[v])return o=c[v];o=c[v]={autoInsertedBrackets:0,autoInsertedRow:-1,autoInsertedLineEnd:"",maybeInsertedBrackets:0,maybeInsertedRow:-1,maybeInsertedLineStart:"",maybeInsertedLineEnd:""}},d=function(_,v,M,y){var I=_.end.row-_.start.row;return{text:M+v+y,selection:[0,_.start.column+1,I,_.end.column+(I?0:1)]}},g=function(_){_=_||{},this.add("braces","insertion",function(v,M,y,I,w){var x=y.getCursorPosition(),N=I.doc.getLine(x.row);if(w=="{"){h(y);var D=y.getSelectionRange(),R=I.doc.getTextRange(D);if(R!==""&&R!=="{"&&y.getWrapBehavioursEnabled())return d(D,R,"{","}");if(g.isSaneInsertion(y,I))return/[\]\}\)]/.test(N[x.column])||y.inMultiSelectMode||_.braces?(g.recordAutoInsert(y,I,"}"),{text:"{}",selection:[1,1]}):(g.recordMaybeInsert(y,I,"{"),{text:"{",selection:[1,1]})}else if(w=="}"){h(y);var S=N.substring(x.column,x.column+1);if(S=="}"){var F=I.$findOpeningBracket("}",{column:x.column+1,row:x.row});if(F!==null&&g.isAutoInsertedClosing(x,N,w))return g.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}else if(w==` +`||w==`\r +`){h(y);var A="";g.isMaybeInsertedClosing(x,N)&&(A=f.stringRepeat("}",o.maybeInsertedBrackets),g.clearMaybeInsertedClosing());var S=N.substring(x.column,x.column+1);if(S==="}"){var E=I.findMatchingBracket({row:x.row,column:x.column+1},"}");if(!E)return null;var O=this.$getIndent(I.getLine(E.row))}else if(A)var O=this.$getIndent(N);else{g.clearMaybeInsertedClosing();return}var k=O+I.getTabString();return{text:` +`+k+` +`+O+A,selection:[1,k.length,1,k.length]}}else g.clearMaybeInsertedClosing()}),this.add("braces","deletion",function(v,M,y,I,w){var x=I.doc.getTextRange(w);if(!w.isMultiLine()&&x=="{"){h(y);var N=I.doc.getLine(w.start.row),D=N.substring(w.end.column,w.end.column+1);if(D=="}")return w.end.column++,w;o.maybeInsertedBrackets--}}),this.add("parens","insertion",function(v,M,y,I,w){if(w=="("){h(y);var x=y.getSelectionRange(),N=I.doc.getTextRange(x);if(N!==""&&y.getWrapBehavioursEnabled())return d(x,N,"(",")");if(g.isSaneInsertion(y,I))return g.recordAutoInsert(y,I,")"),{text:"()",selection:[1,1]}}else if(w==")"){h(y);var D=y.getCursorPosition(),R=I.doc.getLine(D.row),S=R.substring(D.column,D.column+1);if(S==")"){var F=I.$findOpeningBracket(")",{column:D.column+1,row:D.row});if(F!==null&&g.isAutoInsertedClosing(D,R,w))return g.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(v,M,y,I,w){var x=I.doc.getTextRange(w);if(!w.isMultiLine()&&x=="("){h(y);var N=I.doc.getLine(w.start.row),D=N.substring(w.start.column+1,w.start.column+2);if(D==")")return w.end.column++,w}}),this.add("brackets","insertion",function(v,M,y,I,w){if(w=="["){h(y);var x=y.getSelectionRange(),N=I.doc.getTextRange(x);if(N!==""&&y.getWrapBehavioursEnabled())return d(x,N,"[","]");if(g.isSaneInsertion(y,I))return g.recordAutoInsert(y,I,"]"),{text:"[]",selection:[1,1]}}else if(w=="]"){h(y);var D=y.getCursorPosition(),R=I.doc.getLine(D.row),S=R.substring(D.column,D.column+1);if(S=="]"){var F=I.$findOpeningBracket("]",{column:D.column+1,row:D.row});if(F!==null&&g.isAutoInsertedClosing(D,R,w))return g.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("brackets","deletion",function(v,M,y,I,w){var x=I.doc.getTextRange(w);if(!w.isMultiLine()&&x=="["){h(y);var N=I.doc.getLine(w.start.row),D=N.substring(w.start.column+1,w.start.column+2);if(D=="]")return w.end.column++,w}}),this.add("string_dquotes","insertion",function(v,M,y,I,w){var x=I.$mode.$quotes||l;if(w.length==1&&x[w]){if(this.lineCommentStart&&this.lineCommentStart.indexOf(w)!=-1)return;h(y);var N=w,D=y.getSelectionRange(),R=I.doc.getTextRange(D);if(R!==""&&(R.length!=1||!x[R])&&y.getWrapBehavioursEnabled())return d(D,R,N,N);if(!R){var S=y.getCursorPosition(),F=I.doc.getLine(S.row),A=F.substring(S.column-1,S.column),E=F.substring(S.column,S.column+1),O=I.getTokenAt(S.row,S.column),k=I.getTokenAt(S.row,S.column+1);if(A=="\\"&&O&&/escape/.test(O.type))return null;var H=O&&/string|escape/.test(O.type),V=!k||/string|escape/.test(k.type),W;if(E==N)W=H!==V,W&&/string\.end/.test(k.type)&&(W=!1);else{if(H&&!V||H&&V)return null;var K=I.$mode.tokenRe;K.lastIndex=0;var Q=K.test(A);K.lastIndex=0;var ie=K.test(E),J=I.$mode.$pairQuotesAfter,Y=J&&J[N]&&J[N].test(A);if(!Y&&Q||ie||E&&!/[\s;,.})\]\\]/.test(E))return null;var z=F[S.column-2];if(A==N&&(z==N||K.test(z)))return null;W=!0}return{text:W?N+N:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(v,M,y,I,w){var x=I.$mode.$quotes||l,N=I.doc.getTextRange(w);if(!w.isMultiLine()&&x.hasOwnProperty(N)){h(y);var D=I.doc.getLine(w.start.row),R=D.substring(w.start.column+1,w.start.column+2);if(R==N)return w.end.column++,w}}),_.closeDocComment!==!1&&this.add("doc comment end","insertion",function(v,M,y,I,w){if(v==="doc-start"&&(w===` +`||w===`\r +`)&&y.selection.isEmpty()){var x=y.getCursorPosition(),N=I.doc.getLine(x.row),D=I.doc.getLine(x.row+1),R=this.$getIndent(N);if(/\s*\*/.test(D))return/^\s*\*/.test(N)?{text:w+R+"* ",selection:[1,3+R.length,1,3+R.length]}:{text:w+R+" * ",selection:[1,3+R.length,1,3+R.length]};if(/\/\*\*/.test(N.substring(0,x.column)))return{text:w+R+" * "+w+" "+R+"*/",selection:[1,4+R.length,1,4+R.length]}}})};g.isSaneInsertion=function(_,v){var M=_.getCursorPosition(),y=new C(v,M.row,M.column);if(!this.$matchTokenType(y.getCurrentToken()||"text",a)){if(/[)}\]]/.test(_.session.getLine(M.row)[M.column]))return!0;var I=new C(v,M.row,M.column+1);if(!this.$matchTokenType(I.getCurrentToken()||"text",a))return!1}return y.stepForward(),y.getCurrentTokenRow()!==M.row||this.$matchTokenType(y.getCurrentToken()||"text",r)},g.$matchTokenType=function(_,v){return v.indexOf(_.type||_)>-1},g.recordAutoInsert=function(_,v,M){var y=_.getCursorPosition(),I=v.doc.getLine(y.row);this.isAutoInsertedClosing(y,I,o.autoInsertedLineEnd[0])||(o.autoInsertedBrackets=0),o.autoInsertedRow=y.row,o.autoInsertedLineEnd=M+I.substr(y.column),o.autoInsertedBrackets++},g.recordMaybeInsert=function(_,v,M){var y=_.getCursorPosition(),I=v.doc.getLine(y.row);this.isMaybeInsertedClosing(y,I)||(o.maybeInsertedBrackets=0),o.maybeInsertedRow=y.row,o.maybeInsertedLineStart=I.substr(0,y.column)+M,o.maybeInsertedLineEnd=I.substr(y.column),o.maybeInsertedBrackets++},g.isAutoInsertedClosing=function(_,v,M){return o.autoInsertedBrackets>0&&_.row===o.autoInsertedRow&&M===o.autoInsertedLineEnd[0]&&v.substr(_.column)===o.autoInsertedLineEnd},g.isMaybeInsertedClosing=function(_,v){return o.maybeInsertedBrackets>0&&_.row===o.maybeInsertedRow&&v.substr(_.column)===o.maybeInsertedLineEnd&&v.substr(0,_.column)==o.maybeInsertedLineStart},g.popAutoInsertedClosing=function(){o.autoInsertedLineEnd=o.autoInsertedLineEnd.substr(1),o.autoInsertedBrackets--},g.clearMaybeInsertedClosing=function(){o&&(o.maybeInsertedBrackets=0,o.maybeInsertedRow=-1)},B.inherits(g,P),p.CstyleBehaviour=g}),ace.define("ace/unicode",["require","exports","module"],function(s,p,m){for(var B=[48,9,8,25,5,0,2,25,48,0,11,0,5,0,6,22,2,30,2,457,5,11,15,4,8,0,2,0,18,116,2,1,3,3,9,0,2,2,2,0,2,19,2,82,2,138,2,4,3,155,12,37,3,0,8,38,10,44,2,0,2,1,2,1,2,0,9,26,6,2,30,10,7,61,2,9,5,101,2,7,3,9,2,18,3,0,17,58,3,100,15,53,5,0,6,45,211,57,3,18,2,5,3,11,3,9,2,1,7,6,2,2,2,7,3,1,3,21,2,6,2,0,4,3,3,8,3,1,3,3,9,0,5,1,2,4,3,11,16,2,2,5,5,1,3,21,2,6,2,1,2,1,2,1,3,0,2,4,5,1,3,2,4,0,8,3,2,0,8,15,12,2,2,8,2,2,2,21,2,6,2,1,2,4,3,9,2,2,2,2,3,0,16,3,3,9,18,2,2,7,3,1,3,21,2,6,2,1,2,4,3,8,3,1,3,2,9,1,5,1,2,4,3,9,2,0,17,1,2,5,4,2,2,3,4,1,2,0,2,1,4,1,4,2,4,11,5,4,4,2,2,3,3,0,7,0,15,9,18,2,2,7,2,2,2,22,2,9,2,4,4,7,2,2,2,3,8,1,2,1,7,3,3,9,19,1,2,7,2,2,2,22,2,9,2,4,3,8,2,2,2,3,8,1,8,0,2,3,3,9,19,1,2,7,2,2,2,22,2,15,4,7,2,2,2,3,10,0,9,3,3,9,11,5,3,1,2,17,4,23,2,8,2,0,3,6,4,0,5,5,2,0,2,7,19,1,14,57,6,14,2,9,40,1,2,0,3,1,2,0,3,0,7,3,2,6,2,2,2,0,2,0,3,1,2,12,2,2,3,4,2,0,2,5,3,9,3,1,35,0,24,1,7,9,12,0,2,0,2,0,5,9,2,35,5,19,2,5,5,7,2,35,10,0,58,73,7,77,3,37,11,42,2,0,4,328,2,3,3,6,2,0,2,3,3,40,2,3,3,32,2,3,3,6,2,0,2,3,3,14,2,56,2,3,3,66,5,0,33,15,17,84,13,619,3,16,2,25,6,74,22,12,2,6,12,20,12,19,13,12,2,2,2,1,13,51,3,29,4,0,5,1,3,9,34,2,3,9,7,87,9,42,6,69,11,28,4,11,5,11,11,39,3,4,12,43,5,25,7,10,38,27,5,62,2,28,3,10,7,9,14,0,89,75,5,9,18,8,13,42,4,11,71,55,9,9,4,48,83,2,2,30,14,230,23,280,3,5,3,37,3,5,3,7,2,0,2,0,2,0,2,30,3,52,2,6,2,0,4,2,2,6,4,3,3,5,5,12,6,2,2,6,67,1,20,0,29,0,14,0,17,4,60,12,5,0,4,11,18,0,5,0,3,9,2,0,4,4,7,0,2,0,2,0,2,3,2,10,3,3,6,4,5,0,53,1,2684,46,2,46,2,132,7,6,15,37,11,53,10,0,17,22,10,6,2,6,2,6,2,6,2,6,2,6,2,6,2,6,2,31,48,0,470,1,36,5,2,4,6,1,5,85,3,1,3,2,2,89,2,3,6,40,4,93,18,23,57,15,513,6581,75,20939,53,1164,68,45,3,268,4,27,21,31,3,13,13,1,2,24,9,69,11,1,38,8,3,102,3,1,111,44,25,51,13,68,12,9,7,23,4,0,5,45,3,35,13,28,4,64,15,10,39,54,10,13,3,9,7,22,4,1,5,66,25,2,227,42,2,1,3,9,7,11171,13,22,5,48,8453,301,3,61,3,105,39,6,13,4,6,11,2,12,2,4,2,0,2,1,2,1,2,107,34,362,19,63,3,53,41,11,5,15,17,6,13,1,25,2,33,4,2,134,20,9,8,25,5,0,2,25,12,88,4,5,3,5,3,5,3,2],P=0,C=[],f=0;f2?z%w!=w-1:z%w==0}}else{if(!this.blockComment)return!1;var N=this.blockComment.start,D=this.blockComment.end,R=new RegExp("^(\\s*)(?:"+r.escapeRegExp(N)+")"),S=new RegExp("(?:"+r.escapeRegExp(D)+")\\s*$"),F=function(W,K){E(W,K)||(!M||/\S/.test(W))&&(v.insertInLine({row:K,column:W.length},D),v.insertInLine({row:K,column:I},N))},A=function(W,K){var Q;(Q=W.match(S))&&v.removeInLine(K,W.length-Q[0].length,W.length),(Q=W.match(R))&&v.removeInLine(K,Q[1].length,Q[0].length)},E=function(W,K){if(R.test(W))return!0;for(var Q=d.getTokens(K),ie=0;ieW.length&&(V=W.length)}),I==1/0&&(I=V,M=!1,y=!1),x&&I%w!=0&&(I=Math.floor(I/w)*w),H(y?A:F)},this.toggleBlockComment=function(h,d,g,_){var v=this.blockComment;if(v){!v.start&&v[0]&&(v=v[0]);var M=new o(d,_.row,_.column),y=M.getCurrentToken();d.selection;var I=d.selection.toOrientedRange(),w,x;if(y&&/comment/.test(y.type)){for(var N,D;y&&/comment/.test(y.type);){var R=y.value.indexOf(v.start);if(R!=-1){var S=M.getCurrentTokenRow(),F=M.getCurrentTokenColumn()+R;N=new c(S,F,S,F+v.start.length);break}y=M.stepBackward()}for(var M=new o(d,_.row,_.column),y=M.getCurrentToken();y&&/comment/.test(y.type);){var R=y.value.indexOf(v.end);if(R!=-1){var S=M.getCurrentTokenRow(),F=M.getCurrentTokenColumn()+R;D=new c(S,F,S,F+v.end.length);break}y=M.stepForward()}D&&d.remove(D),N&&(d.remove(N),w=N.start.row,x=-v.start.length)}else x=v.start.length,w=g.start.row,d.insert(g.end,v.end),d.insert(g.start,v.start);I.start.row==w&&(I.start.column+=x),I.end.row==w&&(I.end.column+=x),d.selection.fromOrientedRange(I)}},this.getNextLineIndent=function(h,d,g){return this.$getIndent(d)},this.checkOutdent=function(h,d,g){return!1},this.autoOutdent=function(h,d,g){},this.$getIndent=function(h){return h.match(/^\s*/)[0]},this.createWorker=function(h){return null},this.createModeDelegates=function(h){this.$embeds=[],this.$modes={};for(var d in h)if(h[d]){var g=h[d],_=g.prototype.$id,v=B.$modes[_];v||(B.$modes[_]=v=new g),B.$modes[d]||(B.$modes[d]=v),this.$embeds.push(d),this.$modes[d]=v}for(var M=["toggleBlockComment","toggleCommentLines","getNextLineIndent","checkOutdent","autoOutdent","transformAction","getCompletions"],d=0;d"u"?this.setPosition(c.row,c.column):this.setPosition(c,l)}return r.prototype.getPosition=function(){return this.$clipPositionToDocument(this.row,this.column)},r.prototype.getDocument=function(){return this.document},r.prototype.onChange=function(o){if(!(o.start.row==o.end.row&&o.start.row!=this.row)&&!(o.start.row>this.row)){var c=a(o,{row:this.row,column:this.column},this.$insertRight);this.setPosition(c.row,c.column,!0)}},r.prototype.setPosition=function(o,c,l){var h;if(l?h={row:o,column:c}:h=this.$clipPositionToDocument(o,c),!(this.row==h.row&&this.column==h.column)){var d={row:this.row,column:this.column};this.row=h.row,this.column=h.column,this._signal("change",{old:d,value:h})}},r.prototype.detach=function(){this.document.off("change",this.$onChange)},r.prototype.attach=function(o){this.document=o||this.document,this.document.on("change",this.$onChange)},r.prototype.$clipPositionToDocument=function(o,c){var l={};return o>=this.document.getLength()?(l.row=Math.max(0,this.document.getLength()-1),l.column=this.document.getLine(l.row).length):o<0?(l.row=0,l.column=0):(l.row=o,l.column=Math.min(this.document.getLine(l.row).length,Math.max(0,c))),c<0&&(l.column=0),l},r}();C.prototype.$insertRight=!1,B.implement(C.prototype,P);function f(r,o,c){var l=c?r.column<=o.column:r.column=h&&(c=h-1,l=void 0);var d=this.getLine(c);return l==null&&(l=d.length),l=Math.min(Math.max(l,0),d.length),{row:c,column:l}},o.prototype.clonePos=function(c){return{row:c.row,column:c.column}},o.prototype.pos=function(c,l){return{row:c,column:l}},o.prototype.$clipPosition=function(c){var l=this.getLength();return c.row>=l?(c.row=Math.max(0,l-1),c.column=this.getLine(l-1).length):(c.row=Math.max(0,c.row),c.column=Math.min(Math.max(c.column,0),this.getLine(c.row).length)),c},o.prototype.insertFullLines=function(c,l){c=Math.min(Math.max(c,0),this.getLength());var h=0;c0,d=l=0&&this.applyDelta({start:this.pos(c,this.getLine(c).length),end:this.pos(c+1,0),action:"remove",lines:["",""]})},o.prototype.replace=function(c,l){if(c instanceof f||(c=f.fromPoints(c.start,c.end)),l.length===0&&c.isEmpty())return c.start;if(l==this.getTextRange(c))return c.end;this.remove(c);var h;return l?h=this.insert(c.start,l):h=c.start,h},o.prototype.applyDeltas=function(c){for(var l=0;l=0;l--)this.revertDelta(c[l])},o.prototype.applyDelta=function(c,l){var h=c.action=="insert";(h?c.lines.length<=1&&!c.lines[0]:!f.comparePoints(c.start,c.end))||(h&&c.lines.length>2e4?this.$splitAndapplyLargeDelta(c,2e4):(P(this.$lines,c,l),this._signal("change",c)))},o.prototype.$safeApplyDelta=function(c){var l=this.$lines.length;(c.action=="remove"&&c.start.row20){o.running=setTimeout(o.$worker,20);break}}o.currentLine=l,h==-1&&(h=l),g<=h&&o.fireUpdateEvent(g,h)}}}return f.prototype.setTokenizer=function(a){this.tokenizer=a,this.lines=[],this.states=[],this.start(0)},f.prototype.setDocument=function(a){this.doc=a,this.lines=[],this.states=[],this.stop()},f.prototype.fireUpdateEvent=function(a,s){var o={first:a,last:s};this._signal("update",{data:o})},f.prototype.start=function(a){this.currentLine=Math.min(a||0,this.currentLine,this.doc.getLength()),this.lines.splice(this.currentLine,this.lines.length),this.states.splice(this.currentLine,this.states.length),this.stop(),this.running=setTimeout(this.$worker,700)},f.prototype.scheduleStart=function(){this.running||(this.running=setTimeout(this.$worker,700))},f.prototype.$updateOnChange=function(a){var s=a.start.row,o=a.end.row-s;if(o===0)this.lines[s]=null;else if(a.action=="remove")this.lines.splice(s,o+1,null),this.states.splice(s,o+1,null);else{var c=Array(o+1);c.unshift(s,1),this.lines.splice.apply(this.lines,c),this.states.splice.apply(this.states,c)}this.currentLine=Math.min(s,this.currentLine,this.doc.getLength()),this.stop()},f.prototype.stop=function(){this.running&&clearTimeout(this.running),this.running=!1},f.prototype.getTokens=function(a){return this.lines[a]||this.$tokenizeRow(a)},f.prototype.getState=function(a){return this.currentLine==a&&this.$tokenizeRow(a),this.states[a]||"start"},f.prototype.$tokenizeRow=function(a){var s=this.doc.getLine(a),o=this.states[a-1],c=this.tokenizer.getLineTokens(s,o,a);return this.states[a]+""!=c.state+""?(this.states[a]=c.state,this.lines[a+1]=null,this.currentLine>a+1&&(this.currentLine=a+1)):this.currentLine==a&&(this.currentLine=a+1),this.lines[a]=c.tokens},f.prototype.cleanup=function(){this.running=!1,this.lines=[],this.states=[],this.currentLine=0,this.removeAllListeners()},f}();B.implement(C.prototype,P),p.BackgroundTokenizer=C}),ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/range"],function(r,p,m){var B=r("./lib/lang"),P=r("./range").Range,C=function(){function f(a,s,o){o===void 0&&(o="text"),this.setRegexp(a),this.clazz=s,this.type=o}return f.prototype.setRegexp=function(a){this.regExp+""!=a+""&&(this.regExp=a,this.cache=[])},f.prototype.update=function(a,s,o,c){if(this.regExp)for(var l=c.firstRow,h=c.lastRow,d={},g=l;g<=h;g++){var _=this.cache[g];_==null&&(_=B.getMatchOffsets(o.getLine(g),this.regExp),_.length>this.MAX_RANGES&&(_=_.slice(0,this.MAX_RANGES)),_=_.map(function(S){return new P(g,S.offset,g,S.offset+S.length)}),this.cache[g]=_.length?_:"");for(var v=_.length;v--;){var k=_[v].toScreenRange(o),I=k.toString();d[I]||(d[I]=!0,s.drawSingleLineMarker(a,k,this.clazz,c))}}},f}();C.prototype.MAX_RANGES=500,p.SearchHighlight=C}),ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"],function(r,p,m){var B=r("../range").Range,P=function(){function C(f,a){this.foldData=f,Array.isArray(a)?this.folds=a:a=this.folds=[a];var s=a[a.length-1];this.range=new B(a[0].start.row,a[0].start.column,s.end.row,s.end.column),this.start=this.range.start,this.end=this.range.end,this.folds.forEach(function(o){o.setFoldLine(this)},this)}return C.prototype.shiftRow=function(f){this.start.row+=f,this.end.row+=f,this.folds.forEach(function(a){a.start.row+=f,a.end.row+=f})},C.prototype.addFold=function(f){if(f.sameRow){if(f.start.rowthis.endRow)throw new Error("Can't add a fold to this FoldLine as it has no connection");this.folds.push(f),this.folds.sort(function(a,s){return-a.range.compareEnd(s.start.row,s.start.column)}),this.range.compareEnd(f.start.row,f.start.column)>0?(this.end.row=f.end.row,this.end.column=f.end.column):this.range.compareStart(f.end.row,f.end.column)<0&&(this.start.row=f.start.row,this.start.column=f.start.column)}else if(f.start.row==this.end.row)this.folds.push(f),this.end.row=f.end.row,this.end.column=f.end.column;else if(f.end.row==this.start.row)this.folds.unshift(f),this.start.row=f.start.row,this.start.column=f.start.column;else throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");f.foldLine=this},C.prototype.containsRow=function(f){return f>=this.start.row&&f<=this.end.row},C.prototype.walk=function(f,a,s){var o=0,c=this.folds,l,h,d,g=!0;a==null&&(a=this.end.row,s=this.end.column);for(var _=0;_0)){var g=P(a,h.start);return d===0?s&&g!==0?-l-2:l:g>0||g===0&&!s?l:-l-1}}return-l-1},f.prototype.add=function(a){var s=!a.isEmpty(),o=this.pointIndex(a.start,s);o<0&&(o=-o-1);var c=this.pointIndex(a.end,s,o);return c<0?c=-c-1:c++,this.ranges.splice(o,c-o,a)},f.prototype.addList=function(a){for(var s=[],o=a.length;o--;)s.push.apply(s,this.add(a[o]));return s},f.prototype.substractPoint=function(a){var s=this.pointIndex(a);if(s>=0)return this.ranges.splice(s,1)},f.prototype.merge=function(){var a=[],s=this.ranges;s=s.sort(function(d,g){return P(d.start,g.start)});for(var o=s[0],c,l=1;l=0},f.prototype.containsPoint=function(a){return this.pointIndex(a)>=0},f.prototype.rangeAtPoint=function(a){var s=this.pointIndex(a);if(s>=0)return this.ranges[s]},f.prototype.clipRows=function(a,s){var o=this.ranges;if(o[0].start.row>s||o[o.length-1].start.row=c)break}if(a.action=="insert")for(var v=l-c,k=-s.column+o.column;dc)break;if(_.start.row==c&&_.start.column>=s.column&&(_.start.column==s.column&&this.$bias<=0||(_.start.column+=k,_.start.row+=v)),_.end.row==c&&_.end.column>=s.column){if(_.end.column==s.column&&this.$bias<0)continue;_.end.column==s.column&&k>0&&d_.start.column&&_.end.column==h[d+1].start.column&&(_.end.column-=k),_.end.column+=k,_.end.row+=v}}else for(var v=c-l,k=s.column-o.column;dl)break;_.end.rows.column)&&(_.end.column=s.column,_.end.row=s.row):(_.end.column+=k,_.end.row+=v):_.end.row>l&&(_.end.row+=v),_.start.rows.column)&&(_.start.column=s.column,_.start.row=s.row):(_.start.column+=k,_.start.row+=v):_.start.row>l&&(_.start.row+=v)}if(v!=0&&d=o)return d;if(d.end.row>o)return null}return null},this.getNextFoldLine=function(o,c){var l=this.$foldData,h=0;for(c&&(h=l.indexOf(c)),h==-1&&(h=0),h;h=o)return d}return null},this.getFoldedRowCount=function(o,c){for(var l=this.$foldData,h=c-o+1,d=0;d=c){v=o?h-=c-v:h=0);break}else _>=o&&(v>=o?h-=_-v:h-=_-o+1)}return h},this.$addFoldLine=function(o){return this.$foldData.push(o),this.$foldData.sort(function(c,l){return c.start.row-l.start.row}),o},this.addFold=function(o,c){var l=this.$foldData,h=!1,d;o instanceof C?d=o:(d=new C(c,o),d.collapseChildren=c.collapseChildren),this.$clipRangeToDocument(d.range);var g=d.start.row,_=d.start.column,v=d.end.row,k=d.end.column,I=this.getFoldAt(g,_,1),S=this.getFoldAt(v,k,-1);if(I&&S==I)return I.addSubFold(d);I&&!I.range.isStart(g,_)&&this.removeFold(I),S&&!S.range.isEnd(v,k)&&this.removeFold(S);var b=this.getFoldsInRange(d.range);b.length>0&&(this.removeFolds(b),d.collapseChildren||b.forEach(function(R){d.addSubFold(R)}));for(var x=0;x0&&this.foldAll(o.start.row+1,o.end.row,o.collapseChildren-1),o.subFolds=[]},this.expandFolds=function(o){o.forEach(function(c){this.expandFold(c)},this)},this.unfold=function(o,c){var l,h;if(o==null)l=new B(0,0,this.getLength(),0),c==null&&(c=!0);else if(typeof o=="number")l=new B(o,0,o,this.getLine(o).length);else if("row"in o)l=B.fromPoints(o,o);else{if(Array.isArray(o))return h=[],o.forEach(function(g){h=h.concat(this.unfold(g))},this),h;l=o}h=this.getFoldsInRangeList(l);for(var d=h;h.length==1&&B.comparePoints(h[0].start,l.start)<0&&B.comparePoints(h[0].end,l.end)>0;)this.expandFolds(h),h=this.getFoldsInRangeList(l);if(c!=!1?this.removeFolds(h):this.expandFolds(h),d.length)return d},this.isRowFolded=function(o,c){return!!this.getFoldLine(o,c)},this.getRowFoldEnd=function(o,c){var l=this.getFoldLine(o,c);return l?l.end.row:o},this.getRowFoldStart=function(o,c){var l=this.getFoldLine(o,c);return l?l.start.row:o},this.getFoldDisplayLine=function(o,c,l,h,d){h==null&&(h=o.start.row),d==null&&(d=0),c==null&&(c=o.end.row),l==null&&(l=this.getLine(c).length);var g=this.doc,_="";return o.walk(function(v,k,I,S){if(!(kk)break;while(d&&_.test(d.type)&&!/^comment.start/.test(d.type));d=h.stepBackward()}else d=h.getCurrentToken();return v.end.row=h.getCurrentTokenRow(),v.end.column=h.getCurrentTokenColumn(),/^comment.end/.test(d.type)||(v.end.column+=d.value.length-2),v}},this.foldAll=function(o,c,l,h){l==null&&(l=1e5);var d=this.foldWidgets;if(d){c=c||this.getLength(),o=o||0;for(var g=o;g=o&&(g=_.end.row,_.collapseChildren=l,this.addFold("...",_))}}},this.foldToLevel=function(o){for(this.foldAll();o-- >0;)this.unfold(null,!1)},this.foldAllComments=function(){var o=this;this.foldAll(null,null,null,function(c){for(var l=o.getTokens(c),h=0;h=0;){var g=l[h];if(g==null&&(g=l[h]=this.getFoldWidget(h)),g=="start"){var _=this.getFoldWidgetRange(h);if(d||(d=_),_&&_.end.row>=o)break}h--}return{range:h!==-1&&_,firstRange:d}},this.onFoldWidgetClick=function(o,c){c instanceof a&&(c=c.domEvent);var l={children:c.shiftKey,all:c.ctrlKey||c.metaKey,siblings:c.altKey},h=this.$toggleFoldWidget(o,l);if(!h){var d=c.target||c.srcElement;d&&/ace_fold-widget/.test(d.className)&&(d.className+=" ace_invalid")}},this.$toggleFoldWidget=function(o,c){if(this.getFoldWidget){var l=this.getFoldWidget(o),h=this.getLine(o),d=l==="end"?-1:1,g=this.getFoldAt(o,d===-1?0:h.length,d);if(g)return c.children||c.all?this.removeFold(g):this.expandFold(g),g;var _=this.getFoldWidgetRange(o,!0);if(_&&!_.isMultiLine()&&(g=this.getFoldAt(_.start.row,_.start.column,1),g&&_.isEqual(g.range)))return this.removeFold(g),g;if(c.siblings){var v=this.getParentFoldRangeData(o);if(v.range)var k=v.range.start.row+1,I=v.range.end.row;this.foldAll(k,I,c.all?1e4:0)}else c.children?(I=_?_.end.row:this.getLength(),this.foldAll(o+1,I,c.all?1e4:0)):_&&(c.all&&(_.collapseChildren=1e4),this.addFold("...",_));return _}},this.toggleFoldWidget=function(o){var c=this.selection.getCursor().row;c=this.getRowFoldStart(c);var l=this.$toggleFoldWidget(c,{});if(!l){var h=this.getParentFoldRangeData(c,!0);if(l=h.range||h.firstRange,l){c=l.start.row;var d=this.getFoldAt(c,this.getLine(c).length,1);d?this.removeFold(d):this.addFold("...",l)}}},this.updateFoldWidgets=function(o){var c=o.start.row,l=o.end.row-c;if(l===0)this.foldWidgets[c]=null;else if(o.action=="remove")this.foldWidgets.splice(c,l+1,null);else{var h=Array(l+1);h.unshift(c,1),this.foldWidgets.splice.apply(this.foldWidgets,h)}},this.tokenizerUpdateFoldWidgets=function(o){var c=o.data;c.first!=c.last&&this.foldWidgets.length>c.first&&this.foldWidgets.splice(c.first,this.foldWidgets.length)}}p.Folding=s}),ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"],function(r,p,m){var B=r("../token_iterator").TokenIterator,P=r("../range").Range;function C(){this.findMatchingBracket=function(f,a){if(f.column==0)return null;var s=a||this.getLine(f.row).charAt(f.column-1);if(s=="")return null;var o=s.match(/([\(\[\{])|([\)\]\}])/);return o?o[1]?this.$findClosingBracket(o[1],f):this.$findOpeningBracket(o[2],f):null},this.getBracketRange=function(f){var a=this.getLine(f.row),s=!0,o,c=a.charAt(f.column-1),l=c&&c.match(/([\(\[\{])|([\)\]\}])/);if(l||(c=a.charAt(f.column),f={row:f.row,column:f.column+1},l=c&&c.match(/([\(\[\{])|([\)\]\}])/),s=!1),!l)return null;if(l[1]){var h=this.$findClosingBracket(l[1],f);if(!h)return null;o=P.fromPoints(f,h),s||(o.end.column++,o.start.column--),o.cursor=o.end}else{var h=this.$findOpeningBracket(l[2],f);if(!h)return null;o=P.fromPoints(h,f),s||(o.start.column++,o.end.column--),o.cursor=o.start}return o},this.getMatchingBracketRanges=function(f,a){var s=this.getLine(f.row),o=/([\(\[\{])|([\)\]\}])/,c=!a&&s.charAt(f.column-1),l=c&&c.match(o);if(l||(c=(a===void 0||a)&&s.charAt(f.column),f={row:f.row,column:f.column+1},l=c&&c.match(o)),!l)return null;var h=new P(f.row,f.column-1,f.row,f.column),d=l[1]?this.$findClosingBracket(l[1],f):this.$findOpeningBracket(l[2],f);if(!d)return[h];var g=new P(d.row,d.column,d.row,d.column+1);return[h,g]},this.$brackets={")":"(","(":")","]":"[","[":"]","{":"}","}":"{","<":">",">":"<"},this.$findOpeningBracket=function(f,a,s){var o=this.$brackets[f],c=1,l=new B(this,a.row,a.column),h=l.getCurrentToken();if(h||(h=l.stepForward()),!!h){s||(s=new RegExp("(\\.?"+h.type.replace(".","\\.").replace("rparen",".paren").replace(/\b(?:end)\b/,"(?:start|begin|end)").replace(/-close\b/,"-(close|open)")+")+"));for(var d=a.column-l.getCurrentTokenColumn()-2,g=h.value;;){for(;d>=0;){var _=g.charAt(d);if(_==o){if(c-=1,c==0)return{row:l.getCurrentTokenRow(),column:d+l.getCurrentTokenColumn()}}else _==f&&(c+=1);d-=1}do h=l.stepBackward();while(h&&!s.test(h.type));if(h==null)break;g=h.value,d=g.length-1}return null}},this.$findClosingBracket=function(f,a,s){var o=this.$brackets[f],c=1,l=new B(this,a.row,a.column),h=l.getCurrentToken();if(h||(h=l.stepForward()),!!h){s||(s=new RegExp("(\\.?"+h.type.replace(".","\\.").replace("lparen",".paren").replace(/\b(?:start|begin)\b/,"(?:start|begin|end)").replace(/-open\b/,"-(close|open)")+")+"));for(var d=a.column-l.getCurrentTokenColumn();;){for(var g=h.value,_=g.length;d<_;){var v=g.charAt(d);if(v==o){if(c-=1,c==0)return{row:l.getCurrentTokenRow(),column:d+l.getCurrentTokenColumn()}}else v==f&&(c+=1);d+=1}do h=l.stepForward();while(h&&!s.test(h.type));if(h==null)break;d=0}return null}},this.getMatchingTags=function(f){var a=new B(this,f.row,f.column),s=this.$findTagName(a);if(s){var o=a.stepBackward();return o.value==="<"?this.$findClosingTag(a,s):this.$findOpeningTag(a,s)}},this.$findTagName=function(f){var a=f.getCurrentToken(),s=!1,o=!1;if(a&&a.type.indexOf("tag-name")===-1)do o?a=f.stepBackward():a=f.stepForward(),a&&(a.value==="/>"?o=!0:a.type.indexOf("tag-name")!==-1&&(s=!0));while(a&&!s);return a},this.$findClosingTag=function(f,a){var s,o=a.value,c=a.value,l=0,h=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);a=f.stepForward();var d=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+a.value.length),g=!1;do if(s=a,a=f.stepForward(),a){if(a.value===">"&&!g){var _=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);g=!0}if(a.type.indexOf("tag-name")!==-1){if(o=a.value,c===o){if(s.value==="<")l++;else if(s.value==="")var I=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);else return}}}else if(c===o&&a.value==="/>"&&(l--,l<0))var v=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+2),k=v,I=k,_=new P(d.end.row,d.end.column,d.end.row,d.end.column+1)}while(a&&l>=0);if(h&&_&&v&&I&&d&&k)return{openTag:new P(h.start.row,h.start.column,_.end.row,_.end.column),closeTag:new P(v.start.row,v.start.column,I.end.row,I.end.column),openTagName:d,closeTagName:k}},this.$findOpeningTag=function(f,a){var s=f.getCurrentToken(),o=a.value,c=0,l=f.getCurrentTokenRow(),h=f.getCurrentTokenColumn(),d=h+2,g=new P(l,h,l,d);f.stepForward();var _=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+a.value.length);if(a=f.stepForward(),!(!a||a.value!==">")){var v=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);f.stepBackward(),f.stepBackward();do if(a=s,l=f.getCurrentTokenRow(),h=f.getCurrentTokenColumn(),d=h+a.value.length,s=f.stepBackward(),a){if(a.type.indexOf("tag-name")!==-1){if(o===a.value)if(s.value==="<"){if(c++,c>0){var k=new P(l,h,l,d),I=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);do a=f.stepForward();while(a&&a.value!==">");var S=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1)}}else s.value===""){for(var b=0,x=s;x;){if(x.type.indexOf("tag-name")!==-1&&x.value===o){c--;break}else if(x.value==="<")break;x=f.stepBackward(),b++}for(var N=0;NA&&(this.$docRowCache.splice(A,F),this.$screenRowCache.splice(A,F))},R.prototype.$getRowCacheIndex=function(w,F){for(var A=0,T=w.length-1;A<=T;){var L=A+T>>1,O=w[L];if(F>O)A=L+1;else if(F=F));O++);return T=A[O],T?(T.index=O,T.start=L-T.value.length,T):null},R.prototype.setUndoManager=function(w){if(this.$undoManager=w,this.$informUndoManager&&this.$informUndoManager.cancel(),w){var F=this;w.addSession(this),this.$syncInformUndoManager=function(){F.$informUndoManager.cancel(),F.mergeUndoDeltas=!1},this.$informUndoManager=P.delayedCall(this.$syncInformUndoManager)}else this.$syncInformUndoManager=function(){}},R.prototype.markUndoGroup=function(){this.$syncInformUndoManager&&this.$syncInformUndoManager()},R.prototype.getUndoManager=function(){return this.$undoManager||this.$defaultUndoManager},R.prototype.getTabString=function(){return this.getUseSoftTabs()?P.stringRepeat(" ",this.getTabSize()):" "},R.prototype.setUseSoftTabs=function(w){this.setOption("useSoftTabs",w)},R.prototype.getUseSoftTabs=function(){return this.$useSoftTabs&&!this.$mode.$indentWithTabs},R.prototype.setTabSize=function(w){this.setOption("tabSize",w)},R.prototype.getTabSize=function(){return this.$tabSize},R.prototype.isTabStop=function(w){return this.$useSoftTabs&&w.column%this.$tabSize===0},R.prototype.setNavigateWithinSoftTabs=function(w){this.setOption("navigateWithinSoftTabs",w)},R.prototype.getNavigateWithinSoftTabs=function(){return this.$navigateWithinSoftTabs},R.prototype.setOverwrite=function(w){this.setOption("overwrite",w)},R.prototype.getOverwrite=function(){return this.$overwrite},R.prototype.toggleOverwrite=function(){this.setOverwrite(!this.$overwrite)},R.prototype.addGutterDecoration=function(w,F){this.$decorations[w]||(this.$decorations[w]=""),this.$decorations[w]+=" "+F,this._signal("changeBreakpoint",{})},R.prototype.removeGutterDecoration=function(w,F){this.$decorations[w]=(this.$decorations[w]||"").replace(" "+F,""),this._signal("changeBreakpoint",{})},R.prototype.getBreakpoints=function(){return this.$breakpoints},R.prototype.setBreakpoints=function(w){this.$breakpoints=[];for(var F=0;F0&&(T=!!A.charAt(F-1).match(this.tokenRe)),T||(T=!!A.charAt(F).match(this.tokenRe)),T)var L=this.tokenRe;else if(/^\s+$/.test(A.slice(F-1,F+1)))var L=/\s/;else var L=this.nonTokenRe;var O=F;if(O>0){do O--;while(O>=0&&A.charAt(O).match(L));O++}for(var H=F;Hw&&(w=F.screenWidth)}),this.lineWidgetWidth=w},R.prototype.$computeWidth=function(w){if(this.$modified||w){if(this.$modified=!1,this.$useWrapMode)return this.screenWidth=this.$wrapLimit;for(var F=this.doc.getAllLines(),A=this.$rowLengthCache,T=0,L=0,O=this.$foldData[L],H=O?O.start.row:1/0,V=F.length,W=0;WH){if(W=O.end.row+1,W>=V)break;O=this.$foldData[L++],H=O?O.start.row:1/0}A[W]==null&&(A[W]=this.$getStringScreenWidth(F[W])[0]),A[W]>T&&(T=A[W])}this.screenWidth=T}},R.prototype.getLine=function(w){return this.doc.getLine(w)},R.prototype.getLines=function(w,F){return this.doc.getLines(w,F)},R.prototype.getLength=function(){return this.doc.getLength()},R.prototype.getTextRange=function(w){return this.doc.getTextRange(w||this.selection.getRange())},R.prototype.insert=function(w,F){return this.doc.insert(w,F)},R.prototype.remove=function(w){return this.doc.remove(w)},R.prototype.removeFullLines=function(w,F){return this.doc.removeFullLines(w,F)},R.prototype.undoChanges=function(w,F){if(w.length){this.$fromUndo=!0;for(var A=w.length-1;A!=-1;A--){var T=w[A];T.action=="insert"||T.action=="remove"?this.doc.revertDelta(T):T.folds&&this.addFolds(T.folds)}!F&&this.$undoSelect&&(w.selectionBefore?this.selection.fromJSON(w.selectionBefore):this.selection.setRange(this.$getUndoSelection(w,!0))),this.$fromUndo=!1}},R.prototype.redoChanges=function(w,F){if(w.length){this.$fromUndo=!0;for(var A=0;Aw.end.column&&(O.start.column+=V),O.end.row==w.end.row&&O.end.column>w.end.column&&(O.end.column+=V)),H&&O.start.row>=w.end.row&&(O.start.row+=H,O.end.row+=H)}if(O.end=this.insert(O.start,T),L.length){var W=w.start,K=O.start,H=K.row-W.row,V=K.column-W.column;this.addFolds(L.map(function(J){return J=J.clone(),J.start.row==W.row&&(J.start.column+=V),J.end.row==W.row&&(J.end.column+=V),J.start.row+=H,J.end.row+=H,J}))}return O},R.prototype.indentRows=function(w,F,A){A=A.replace(/\t/g,this.getTabString());for(var T=w;T<=F;T++)this.doc.insertInLine({row:T,column:0},A)},R.prototype.outdentRows=function(w){for(var F=w.collapseRows(),A=new c(0,0,0,0),T=this.getTabSize(),L=F.start.row;L<=F.end.row;++L){var O=this.getLine(L);A.start.row=L,A.end.row=L;for(var H=0;H0){var T=this.getRowFoldEnd(F+A);if(T>this.doc.getLength()-1)return 0;var L=T-F}else{w=this.$clipRowToDocument(w),F=this.$clipRowToDocument(F);var L=F-w+1}var O=new c(w,0,F,Number.MAX_VALUE),H=this.getFoldsInRange(O).map(function(W){return W=W.clone(),W.start.row+=L,W.end.row+=L,W}),V=A==0?this.doc.getLines(w,F):this.doc.removeFullLines(w,F);return this.doc.insertFullLines(w+L,V),H.length&&this.addFolds(H),L},R.prototype.moveLinesUp=function(w,F){return this.$moveLines(w,F,-1)},R.prototype.moveLinesDown=function(w,F){return this.$moveLines(w,F,1)},R.prototype.duplicateLines=function(w,F){return this.$moveLines(w,F,0)},R.prototype.$clipRowToDocument=function(w){return Math.max(0,Math.min(w,this.doc.getLength()-1))},R.prototype.$clipColumnToRow=function(w,F){return F<0?0:Math.min(this.doc.getLine(w).length,F)},R.prototype.$clipPositionToDocument=function(w,F){if(F=Math.max(0,F),w<0)w=0,F=0;else{var A=this.doc.getLength();w>=A?(w=A-1,F=this.doc.getLine(A-1).length):F=Math.min(this.doc.getLine(w).length,F)}return{row:w,column:F}},R.prototype.$clipRangeToDocument=function(w){w.start.row<0?(w.start.row=0,w.start.column=0):w.start.column=this.$clipColumnToRow(w.start.row,w.start.column);var F=this.doc.getLength()-1;return w.end.row>F?(w.end.row=F,w.end.column=this.doc.getLine(F).length):w.end.column=this.$clipColumnToRow(w.end.row,w.end.column),w},R.prototype.setUseWrapMode=function(w){if(w!=this.$useWrapMode){if(this.$useWrapMode=w,this.$modified=!0,this.$resetRowCache(0),w){var F=this.getLength();this.$wrapData=Array(F),this.$updateWrapData(0,F-1)}this._signal("changeWrapMode")}},R.prototype.getUseWrapMode=function(){return this.$useWrapMode},R.prototype.setWrapLimitRange=function(w,F){(this.$wrapLimitRange.min!==w||this.$wrapLimitRange.max!==F)&&(this.$wrapLimitRange={min:w,max:F},this.$modified=!0,this.$bidiHandler.markAsDirty(),this.$useWrapMode&&this._signal("changeWrapMode"))},R.prototype.adjustWrapLimit=function(w,F){var A=this.$wrapLimitRange;A.max<0&&(A={min:F,max:F});var T=this.$constrainWrapLimit(w,A.min,A.max);return T!=this.$wrapLimit&&T>1?(this.$wrapLimit=T,this.$modified=!0,this.$useWrapMode&&(this.$updateWrapData(0,this.getLength()-1),this.$resetRowCache(0),this._signal("changeWrapLimit")),!0):!1},R.prototype.$constrainWrapLimit=function(w,F,A){return F&&(w=Math.max(F,w)),A&&(w=Math.min(A,w)),w},R.prototype.getWrapLimit=function(){return this.$wrapLimit},R.prototype.setWrapLimit=function(w){this.setWrapLimitRange(w,w)},R.prototype.getWrapLimitRange=function(){return{min:this.$wrapLimitRange.min,max:this.$wrapLimitRange.max}},R.prototype.$updateInternalDataOnChange=function(w){var F=this.$useWrapMode,A=w.action,T=w.start,L=w.end,O=T.row,H=L.row,V=H-O,W=null;if(this.$updating=!0,V!=0)if(A==="remove"){this[F?"$wrapData":"$rowLengthCache"].splice(O,V);var K=this.$foldData;W=this.getFoldsInRange(w),this.removeFolds(W);var Q=this.getFoldLine(L.row),ie=0;if(Q){Q.addRemoveChars(L.row,L.column,T.column-L.column),Q.shiftRow(-V);var J=this.getFoldLine(O);J&&J!==Q&&(J.merge(Q),Q=J),ie=K.indexOf(Q)+1}for(ie;ie=L.row&&Q.shiftRow(-V)}H=O}else{var Y=Array(V);Y.unshift(O,0);var z=F?this.$wrapData:this.$rowLengthCache;z.splice.apply(z,Y);var K=this.$foldData,Q=this.getFoldLine(O),ie=0;if(Q){var oe=Q.range.compareInside(T.row,T.column);oe==0?(Q=Q.split(T.row,T.column),Q&&(Q.shiftRow(V),Q.addRemoveChars(H,0,L.column-T.column))):oe==-1&&(Q.addRemoveChars(O,0,L.column-T.column),Q.shiftRow(V)),ie=K.indexOf(Q)+1}for(ie;ie=O&&Q.shiftRow(V)}}else{V=Math.abs(w.start.column-w.end.column),A==="remove"&&(W=this.getFoldsInRange(w),this.removeFolds(W),V=-V);var Q=this.getFoldLine(O);Q&&Q.addRemoveChars(O,T.column,V)}return F&&this.$wrapData.length!=this.doc.getLength()&&console.error("doc.getLength() and $wrapData.length have to be the same!"),this.$updating=!1,F?this.$updateWrapData(O,H):this.$updateRowLengthCache(O,H),W},R.prototype.$updateRowLengthCache=function(w,F,A){this.$rowLengthCache[w]=null,this.$rowLengthCache[F]=null},R.prototype.$updateWrapData=function(w,F){var A=this.doc.getAllLines(),T=this.getTabSize(),L=this.$wrapData,O=this.$wrapLimit,H,V,W=w;for(F=Math.min(F,A.length-1);W<=F;)V=this.getFoldLine(W,V),V?(H=[],V.walk(function(K,Q,ie,J){var Y;if(K!=null){Y=this.$getDisplayTokens(K,H.length),Y[0]=k;for(var z=1;zF-J;){var Y=O+F-J;if(w[Y-1]>=b&&w[Y]>=b){ie(Y);continue}if(w[Y]==k||w[Y]==I){for(Y;Y!=O-1&&w[Y]!=k;Y--);if(Y>O){ie(Y);continue}for(Y=O+F,Y;Y>2)),O-1);Y>z&&w[Y]z&&w[Y]z&&w[Y]==S;)Y--}else for(;Y>z&&w[Y]z){ie(++Y);continue}Y=O+F,w[Y]==v&&Y--,ie(Y-J)}return T},R.prototype.$getDisplayTokens=function(w,F){var A=[],T;F=F||0;for(var L=0;L39&&O<48||O>57&&O<64?A.push(S):O>=4352&&D(O)?A.push(_,v):A.push(_)}return A},R.prototype.$getStringScreenWidth=function(w,F,A){if(F==0)return[0,0];F==null&&(F=1/0),A=A||0;var T,L;for(L=0;L=4352&&D(T)?A+=2:A+=1,!(A>F));L++);return[A,L]},R.prototype.getRowLength=function(w){var F=1;return this.lineWidgets&&(F+=this.lineWidgets[w]&&this.lineWidgets[w].rowCount||0),!this.$useWrapMode||!this.$wrapData[w]?F:this.$wrapData[w].length+F},R.prototype.getRowLineCount=function(w){return!this.$useWrapMode||!this.$wrapData[w]?1:this.$wrapData[w].length+1},R.prototype.getRowWrapIndent=function(w){if(this.$useWrapMode){var F=this.screenToDocumentPosition(w,Number.MAX_VALUE),A=this.$wrapData[F.row];return A.length&&A[0]=0)var V=K[Q],L=this.$docRowCache[Q],J=w>K[ie-1];else var J=!ie;for(var Y=this.getLength()-1,z=this.getNextFoldLine(L),oe=z?z.start.row:1/0;V<=w&&(W=this.getRowLength(L),!(V+W>w||L>=Y));)V+=W,L++,L>oe&&(L=z.end.row+1,z=this.getNextFoldLine(L,z),oe=z?z.start.row:1/0),J&&(this.$docRowCache.push(L),this.$screenRowCache.push(V));if(z&&z.start.row<=L)T=this.getFoldDisplayLine(z),L=z.start.row;else{if(V+W<=w||L>Y)return{row:Y,column:this.getLine(Y).length};T=this.getLine(L),z=null}var he=0,de=Math.floor(w-V);if(this.$useWrapMode){var fe=this.$wrapData[L];fe&&(H=fe[de],de>0&&fe.length&&(he=fe.indent,O=fe[de-1]||fe[fe.length-1],T=T.substring(O)))}return A!==void 0&&this.$bidiHandler.isBidiRow(V+de,L,de)&&(F=this.$bidiHandler.offsetToCol(A)),O+=this.$getStringScreenWidth(T,F-he)[1],this.$useWrapMode&&O>=H&&(O=H-1),z?z.idxToPosition(O):{row:L,column:O}},R.prototype.documentToScreenPosition=function(w,F){if(typeof F>"u")var A=this.$clipPositionToDocument(w.row,w.column);else A=this.$clipPositionToDocument(w,F);w=A.row,F=A.column;var T=0,L=null,O=null;O=this.getFoldAt(w,F,1),O&&(w=O.start.row,F=O.start.column);var H,V=0,W=this.$docRowCache,K=this.$getRowCacheIndex(W,w),Q=W.length;if(Q&&K>=0)var V=W[K],T=this.$screenRowCache[K],ie=w>W[Q-1];else var ie=!Q;for(var J=this.getNextFoldLine(V),Y=J?J.start.row:1/0;V=Y){if(H=J.end.row+1,H>w)break;J=this.getNextFoldLine(H,J),Y=J?J.start.row:1/0}else H=V+1;T+=this.getRowLength(V),V=H,ie&&(this.$docRowCache.push(V),this.$screenRowCache.push(T))}var z="";J&&V>=Y?(z=this.getFoldDisplayLine(J,w,F),L=J.start.row):(z=this.getLine(w).substring(0,F),L=w);var oe=0;if(this.$useWrapMode){var he=this.$wrapData[L];if(he){for(var de=0;z.length>=he[de];)T++,de++;z=z.substring(he[de-1]||0,z.length),oe=de>0?he.indent:0}}return this.lineWidgets&&this.lineWidgets[V]&&this.lineWidgets[V].rowsAbove&&(T+=this.lineWidgets[V].rowsAbove),{row:T,column:oe+this.$getStringScreenWidth(z)[0]}},R.prototype.documentToScreenColumn=function(w,F){return this.documentToScreenPosition(w,F).column},R.prototype.documentToScreenRow=function(w,F){return this.documentToScreenPosition(w,F).row},R.prototype.getScreenLength=function(){var w=0,F=null;if(this.$useWrapMode)for(var L=this.$wrapData.length,O=0,T=0,F=this.$foldData[T++],H=F?F.start.row:1/0;OH&&(O=F.end.row+1,F=this.$foldData[T++],H=F?F.start.row:1/0)}else{w=this.getLength();for(var A=this.$foldData,T=0;TA));O++);return[T,O]})},R.prototype.destroy=function(){this.destroyed||(this.bgTokenizer.setDocument(null),this.bgTokenizer.cleanup(),this.destroyed=!0),this.$stopWorker(),this.removeAllListeners(),this.doc&&this.doc.off("change",this.$onChange),this.selection.detach()},R}();g.$uid=0,g.prototype.$modes=f.$modes,g.prototype.getValue=g.prototype.toString,g.prototype.$defaultUndoManager={undo:function(){},redo:function(){},hasUndo:function(){},hasRedo:function(){},reset:function(){},add:function(){},addSelection:function(){},startNewGroup:function(){},addSession:function(){}},g.prototype.$overwrite=!1,g.prototype.$mode=null,g.prototype.$modeId=null,g.prototype.$scrollTop=0,g.prototype.$scrollLeft=0,g.prototype.$wrapLimit=80,g.prototype.$useWrapMode=!1,g.prototype.$wrapLimitRange={min:null,max:null},g.prototype.lineWidgets=null,g.prototype.isFullWidth=D,B.implement(g.prototype,a);var _=1,v=2,k=3,I=4,S=9,b=10,x=11,N=12;function D(R){return R<4352?!1:R>=4352&&R<=4447||R>=4515&&R<=4519||R>=4602&&R<=4607||R>=9001&&R<=9002||R>=11904&&R<=11929||R>=11931&&R<=12019||R>=12032&&R<=12245||R>=12272&&R<=12283||R>=12288&&R<=12350||R>=12353&&R<=12438||R>=12441&&R<=12543||R>=12549&&R<=12589||R>=12593&&R<=12686||R>=12688&&R<=12730||R>=12736&&R<=12771||R>=12784&&R<=12830||R>=12832&&R<=12871||R>=12880&&R<=13054||R>=13056&&R<=19903||R>=19968&&R<=42124||R>=42128&&R<=42182||R>=43360&&R<=43388||R>=44032&&R<=55203||R>=55216&&R<=55238||R>=55243&&R<=55291||R>=63744&&R<=64255||R>=65040&&R<=65049||R>=65072&&R<=65106||R>=65108&&R<=65126||R>=65128&&R<=65131||R>=65281&&R<=65376||R>=65504&&R<=65510}r("./edit_session/folding").Folding.call(g.prototype),r("./edit_session/bracket_match").BracketMatch.call(g.prototype),f.defineOptions(g.prototype,"session",{wrap:{set:function(R){if(!R||R=="off"?R=!1:R=="free"?R=!0:R=="printMargin"?R=-1:typeof R=="string"&&(R=parseInt(R,10)||!1),this.$wrap!=R)if(this.$wrap=R,!R)this.setUseWrapMode(!1);else{var w=typeof R=="number"?R:null;this.setWrapLimitRange(w,w),this.setUseWrapMode(!0)}},get:function(){return this.getUseWrapMode()?this.$wrap==-1?"printMargin":this.getWrapLimitRange().min?this.$wrap:"free":"off"},handlesSet:!0},wrapMethod:{set:function(R){R=R=="auto"?this.$mode.type!="text":R!="text",R!=this.$wrapAsCode&&(this.$wrapAsCode=R,this.$useWrapMode&&(this.$useWrapMode=!1,this.setUseWrapMode(!0)))},initialValue:"auto"},indentedSoftWrap:{set:function(){this.$useWrapMode&&(this.$useWrapMode=!1,this.setUseWrapMode(!0))},initialValue:!0},firstLineNumber:{set:function(){this._signal("changeBreakpoint")},initialValue:1},useWorker:{set:function(R){this.$useWorker=R,this.$stopWorker(),R&&this.$startWorker()},initialValue:!0},useSoftTabs:{initialValue:!0},tabSize:{set:function(R){R=parseInt(R),R>0&&this.$tabSize!==R&&(this.$modified=!0,this.$rowLengthCache=[],this.$tabSize=R,this._signal("changeTabSize"))},initialValue:4,handlesSet:!0},navigateWithinSoftTabs:{initialValue:!1},foldStyle:{set:function(R){this.setFoldStyle(R)},handlesSet:!0},overwrite:{set:function(R){this._signal("changeOverwrite")},initialValue:!1},newLineMode:{set:function(R){this.doc.setNewLineMode(R)},get:function(){return this.doc.getNewLineMode()},handlesSet:!0},mode:{set:function(R){this.setMode(R)},get:function(){return this.$modeId},handlesSet:!0}}),p.EditSession=g}),ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(r,p,m){var B=r("./lib/lang"),P=r("./lib/oop"),C=r("./range").Range,f=function(){function s(){this.$options={}}return s.prototype.set=function(o){return P.mixin(this.$options,o),this},s.prototype.getOptions=function(){return B.copyObject(this.$options)},s.prototype.setOptions=function(o){this.$options=o},s.prototype.find=function(o){var c=this.$options,l=this.$matchIterator(o,c);if(!l)return!1;var h=null;return l.forEach(function(d,g,_,v){return h=new C(d,g,_,v),g==v&&c.start&&c.start.start&&c.skipCurrent!=!1&&h.isEqual(c.start)?(h=null,!1):!0}),h},s.prototype.findAll=function(o){var c=this.$options;if(!c.needle)return[];this.$assembleRegExp(c);var l=c.range,h=l?o.getLines(l.start.row,l.end.row):o.doc.getAllLines(),d=[],g=c.re;if(c.$isMultiLine){var _=g.length,v=h.length-_,k;e:for(var I=g.offset||0;I<=v;I++){for(var S=0;S<_;S++)if(h[I+S].search(g[S])==-1)continue e;var b=h[I],x=h[I+_-1],N=b.length-b.match(g[0])[0].length,D=x.match(g[_-1])[0].length;k&&k.end.row===I&&k.end.column>N||(d.push(k=new C(I,N,I+_-1,D)),_>2&&(I=I+_-2))}}else for(var R=0;RT&&d[S].end.row==L;)S--;for(d=d.slice(R,S+1),R=0,S=d.length;R=h&&(c=h-1,l=void 0);var d=this.getLine(c);return l==null&&(l=d.length),l=Math.min(Math.max(l,0),d.length),{row:c,column:l}},o.prototype.clonePos=function(c){return{row:c.row,column:c.column}},o.prototype.pos=function(c,l){return{row:c,column:l}},o.prototype.$clipPosition=function(c){var l=this.getLength();return c.row>=l?(c.row=Math.max(0,l-1),c.column=this.getLine(l-1).length):(c.row=Math.max(0,c.row),c.column=Math.min(Math.max(c.column,0),this.getLine(c.row).length)),c},o.prototype.insertFullLines=function(c,l){c=Math.min(Math.max(c,0),this.getLength());var h=0;c0,d=l=0&&this.applyDelta({start:this.pos(c,this.getLine(c).length),end:this.pos(c+1,0),action:"remove",lines:["",""]})},o.prototype.replace=function(c,l){if(c instanceof f||(c=f.fromPoints(c.start,c.end)),l.length===0&&c.isEmpty())return c.start;if(l==this.getTextRange(c))return c.end;this.remove(c);var h;return l?h=this.insert(c.start,l):h=c.start,h},o.prototype.applyDeltas=function(c){for(var l=0;l=0;l--)this.revertDelta(c[l])},o.prototype.applyDelta=function(c,l){var h=c.action=="insert";(h?c.lines.length<=1&&!c.lines[0]:!f.comparePoints(c.start,c.end))||(h&&c.lines.length>2e4?this.$splitAndapplyLargeDelta(c,2e4):(P(this.$lines,c,l),this._signal("change",c)))},o.prototype.$safeApplyDelta=function(c){var l=this.$lines.length;(c.action=="remove"&&c.start.row20){o.running=setTimeout(o.$worker,20);break}}o.currentLine=l,h==-1&&(h=l),g<=h&&o.fireUpdateEvent(g,h)}}}return f.prototype.setTokenizer=function(a){this.tokenizer=a,this.lines=[],this.states=[],this.start(0)},f.prototype.setDocument=function(a){this.doc=a,this.lines=[],this.states=[],this.stop()},f.prototype.fireUpdateEvent=function(a,r){var o={first:a,last:r};this._signal("update",{data:o})},f.prototype.start=function(a){this.currentLine=Math.min(a||0,this.currentLine,this.doc.getLength()),this.lines.splice(this.currentLine,this.lines.length),this.states.splice(this.currentLine,this.states.length),this.stop(),this.running=setTimeout(this.$worker,700)},f.prototype.scheduleStart=function(){this.running||(this.running=setTimeout(this.$worker,700))},f.prototype.$updateOnChange=function(a){var r=a.start.row,o=a.end.row-r;if(o===0)this.lines[r]=null;else if(a.action=="remove")this.lines.splice(r,o+1,null),this.states.splice(r,o+1,null);else{var c=Array(o+1);c.unshift(r,1),this.lines.splice.apply(this.lines,c),this.states.splice.apply(this.states,c)}this.currentLine=Math.min(r,this.currentLine,this.doc.getLength()),this.stop()},f.prototype.stop=function(){this.running&&clearTimeout(this.running),this.running=!1},f.prototype.getTokens=function(a){return this.lines[a]||this.$tokenizeRow(a)},f.prototype.getState=function(a){return this.currentLine==a&&this.$tokenizeRow(a),this.states[a]||"start"},f.prototype.$tokenizeRow=function(a){var r=this.doc.getLine(a),o=this.states[a-1],c=this.tokenizer.getLineTokens(r,o,a);return this.states[a]+""!=c.state+""?(this.states[a]=c.state,this.lines[a+1]=null,this.currentLine>a+1&&(this.currentLine=a+1)):this.currentLine==a&&(this.currentLine=a+1),this.lines[a]=c.tokens},f.prototype.cleanup=function(){this.running=!1,this.lines=[],this.states=[],this.currentLine=0,this.removeAllListeners()},f}();B.implement(C.prototype,P),p.BackgroundTokenizer=C}),ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/range"],function(s,p,m){var B=s("./lib/lang"),P=s("./range").Range,C=function(){function f(a,r,o){o===void 0&&(o="text"),this.setRegexp(a),this.clazz=r,this.type=o}return f.prototype.setRegexp=function(a){this.regExp+""!=a+""&&(this.regExp=a,this.cache=[])},f.prototype.update=function(a,r,o,c){if(this.regExp)for(var l=c.firstRow,h=c.lastRow,d={},g=l;g<=h;g++){var _=this.cache[g];_==null&&(_=B.getMatchOffsets(o.getLine(g),this.regExp),_.length>this.MAX_RANGES&&(_=_.slice(0,this.MAX_RANGES)),_=_.map(function(I){return new P(g,I.offset,g,I.offset+I.length)}),this.cache[g]=_.length?_:"");for(var v=_.length;v--;){var M=_[v].toScreenRange(o),y=M.toString();d[y]||(d[y]=!0,r.drawSingleLineMarker(a,M,this.clazz,c))}}},f}();C.prototype.MAX_RANGES=500,p.SearchHighlight=C}),ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"],function(s,p,m){var B=s("../range").Range,P=function(){function C(f,a){this.foldData=f,Array.isArray(a)?this.folds=a:a=this.folds=[a];var r=a[a.length-1];this.range=new B(a[0].start.row,a[0].start.column,r.end.row,r.end.column),this.start=this.range.start,this.end=this.range.end,this.folds.forEach(function(o){o.setFoldLine(this)},this)}return C.prototype.shiftRow=function(f){this.start.row+=f,this.end.row+=f,this.folds.forEach(function(a){a.start.row+=f,a.end.row+=f})},C.prototype.addFold=function(f){if(f.sameRow){if(f.start.rowthis.endRow)throw new Error("Can't add a fold to this FoldLine as it has no connection");this.folds.push(f),this.folds.sort(function(a,r){return-a.range.compareEnd(r.start.row,r.start.column)}),this.range.compareEnd(f.start.row,f.start.column)>0?(this.end.row=f.end.row,this.end.column=f.end.column):this.range.compareStart(f.end.row,f.end.column)<0&&(this.start.row=f.start.row,this.start.column=f.start.column)}else if(f.start.row==this.end.row)this.folds.push(f),this.end.row=f.end.row,this.end.column=f.end.column;else if(f.end.row==this.start.row)this.folds.unshift(f),this.start.row=f.start.row,this.start.column=f.start.column;else throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");f.foldLine=this},C.prototype.containsRow=function(f){return f>=this.start.row&&f<=this.end.row},C.prototype.walk=function(f,a,r){var o=0,c=this.folds,l,h,d,g=!0;a==null&&(a=this.end.row,r=this.end.column);for(var _=0;_0)){var g=P(a,h.start);return d===0?r&&g!==0?-l-2:l:g>0||g===0&&!r?l:-l-1}}return-l-1},f.prototype.add=function(a){var r=!a.isEmpty(),o=this.pointIndex(a.start,r);o<0&&(o=-o-1);var c=this.pointIndex(a.end,r,o);return c<0?c=-c-1:c++,this.ranges.splice(o,c-o,a)},f.prototype.addList=function(a){for(var r=[],o=a.length;o--;)r.push.apply(r,this.add(a[o]));return r},f.prototype.substractPoint=function(a){var r=this.pointIndex(a);if(r>=0)return this.ranges.splice(r,1)},f.prototype.merge=function(){var a=[],r=this.ranges;r=r.sort(function(d,g){return P(d.start,g.start)});for(var o=r[0],c,l=1;l=0},f.prototype.containsPoint=function(a){return this.pointIndex(a)>=0},f.prototype.rangeAtPoint=function(a){var r=this.pointIndex(a);if(r>=0)return this.ranges[r]},f.prototype.clipRows=function(a,r){var o=this.ranges;if(o[0].start.row>r||o[o.length-1].start.row=c)break}if(a.action=="insert")for(var v=l-c,M=-r.column+o.column;dc)break;if(_.start.row==c&&_.start.column>=r.column&&(_.start.column==r.column&&this.$bias<=0||(_.start.column+=M,_.start.row+=v)),_.end.row==c&&_.end.column>=r.column){if(_.end.column==r.column&&this.$bias<0)continue;_.end.column==r.column&&M>0&&d_.start.column&&_.end.column==h[d+1].start.column&&(_.end.column-=M),_.end.column+=M,_.end.row+=v}}else for(var v=c-l,M=r.column-o.column;dl)break;_.end.rowr.column)&&(_.end.column=r.column,_.end.row=r.row):(_.end.column+=M,_.end.row+=v):_.end.row>l&&(_.end.row+=v),_.start.rowr.column)&&(_.start.column=r.column,_.start.row=r.row):(_.start.column+=M,_.start.row+=v):_.start.row>l&&(_.start.row+=v)}if(v!=0&&d=o)return d;if(d.end.row>o)return null}return null},this.getNextFoldLine=function(o,c){var l=this.$foldData,h=0;for(c&&(h=l.indexOf(c)),h==-1&&(h=0),h;h=o)return d}return null},this.getFoldedRowCount=function(o,c){for(var l=this.$foldData,h=c-o+1,d=0;d=c){v=o?h-=c-v:h=0);break}else _>=o&&(v>=o?h-=_-v:h-=_-o+1)}return h},this.$addFoldLine=function(o){return this.$foldData.push(o),this.$foldData.sort(function(c,l){return c.start.row-l.start.row}),o},this.addFold=function(o,c){var l=this.$foldData,h=!1,d;o instanceof C?d=o:(d=new C(c,o),d.collapseChildren=c.collapseChildren),this.$clipRangeToDocument(d.range);var g=d.start.row,_=d.start.column,v=d.end.row,M=d.end.column,y=this.getFoldAt(g,_,1),I=this.getFoldAt(v,M,-1);if(y&&I==y)return y.addSubFold(d);y&&!y.range.isStart(g,_)&&this.removeFold(y),I&&!I.range.isEnd(v,M)&&this.removeFold(I);var w=this.getFoldsInRange(d.range);w.length>0&&(this.removeFolds(w),d.collapseChildren||w.forEach(function(R){d.addSubFold(R)}));for(var x=0;x0&&this.foldAll(o.start.row+1,o.end.row,o.collapseChildren-1),o.subFolds=[]},this.expandFolds=function(o){o.forEach(function(c){this.expandFold(c)},this)},this.unfold=function(o,c){var l,h;if(o==null)l=new B(0,0,this.getLength(),0),c==null&&(c=!0);else if(typeof o=="number")l=new B(o,0,o,this.getLine(o).length);else if("row"in o)l=B.fromPoints(o,o);else{if(Array.isArray(o))return h=[],o.forEach(function(g){h=h.concat(this.unfold(g))},this),h;l=o}h=this.getFoldsInRangeList(l);for(var d=h;h.length==1&&B.comparePoints(h[0].start,l.start)<0&&B.comparePoints(h[0].end,l.end)>0;)this.expandFolds(h),h=this.getFoldsInRangeList(l);if(c!=!1?this.removeFolds(h):this.expandFolds(h),d.length)return d},this.isRowFolded=function(o,c){return!!this.getFoldLine(o,c)},this.getRowFoldEnd=function(o,c){var l=this.getFoldLine(o,c);return l?l.end.row:o},this.getRowFoldStart=function(o,c){var l=this.getFoldLine(o,c);return l?l.start.row:o},this.getFoldDisplayLine=function(o,c,l,h,d){h==null&&(h=o.start.row),d==null&&(d=0),c==null&&(c=o.end.row),l==null&&(l=this.getLine(c).length);var g=this.doc,_="";return o.walk(function(v,M,y,I){if(!(MM)break;while(d&&_.test(d.type)&&!/^comment.start/.test(d.type));d=h.stepBackward()}else d=h.getCurrentToken();return v.end.row=h.getCurrentTokenRow(),v.end.column=h.getCurrentTokenColumn(),/^comment.end/.test(d.type)||(v.end.column+=d.value.length-2),v}},this.foldAll=function(o,c,l,h){l==null&&(l=1e5);var d=this.foldWidgets;if(d){c=c||this.getLength(),o=o||0;for(var g=o;g=o&&(g=_.end.row,_.collapseChildren=l,this.addFold("...",_))}}},this.foldToLevel=function(o){for(this.foldAll();o-- >0;)this.unfold(null,!1)},this.foldAllComments=function(){var o=this;this.foldAll(null,null,null,function(c){for(var l=o.getTokens(c),h=0;h=0;){var g=l[h];if(g==null&&(g=l[h]=this.getFoldWidget(h)),g=="start"){var _=this.getFoldWidgetRange(h);if(d||(d=_),_&&_.end.row>=o)break}h--}return{range:h!==-1&&_,firstRange:d}},this.onFoldWidgetClick=function(o,c){c instanceof a&&(c=c.domEvent);var l={children:c.shiftKey,all:c.ctrlKey||c.metaKey,siblings:c.altKey},h=this.$toggleFoldWidget(o,l);if(!h){var d=c.target||c.srcElement;d&&/ace_fold-widget/.test(d.className)&&(d.className+=" ace_invalid")}},this.$toggleFoldWidget=function(o,c){if(this.getFoldWidget){var l=this.getFoldWidget(o),h=this.getLine(o),d=l==="end"?-1:1,g=this.getFoldAt(o,d===-1?0:h.length,d);if(g)return c.children||c.all?this.removeFold(g):this.expandFold(g),g;var _=this.getFoldWidgetRange(o,!0);if(_&&!_.isMultiLine()&&(g=this.getFoldAt(_.start.row,_.start.column,1),g&&_.isEqual(g.range)))return this.removeFold(g),g;if(c.siblings){var v=this.getParentFoldRangeData(o);if(v.range)var M=v.range.start.row+1,y=v.range.end.row;this.foldAll(M,y,c.all?1e4:0)}else c.children?(y=_?_.end.row:this.getLength(),this.foldAll(o+1,y,c.all?1e4:0)):_&&(c.all&&(_.collapseChildren=1e4),this.addFold("...",_));return _}},this.toggleFoldWidget=function(o){var c=this.selection.getCursor().row;c=this.getRowFoldStart(c);var l=this.$toggleFoldWidget(c,{});if(!l){var h=this.getParentFoldRangeData(c,!0);if(l=h.range||h.firstRange,l){c=l.start.row;var d=this.getFoldAt(c,this.getLine(c).length,1);d?this.removeFold(d):this.addFold("...",l)}}},this.updateFoldWidgets=function(o){var c=o.start.row,l=o.end.row-c;if(l===0)this.foldWidgets[c]=null;else if(o.action=="remove")this.foldWidgets.splice(c,l+1,null);else{var h=Array(l+1);h.unshift(c,1),this.foldWidgets.splice.apply(this.foldWidgets,h)}},this.tokenizerUpdateFoldWidgets=function(o){var c=o.data;c.first!=c.last&&this.foldWidgets.length>c.first&&this.foldWidgets.splice(c.first,this.foldWidgets.length)}}p.Folding=r}),ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"],function(s,p,m){var B=s("../token_iterator").TokenIterator,P=s("../range").Range;function C(){this.findMatchingBracket=function(f,a){if(f.column==0)return null;var r=a||this.getLine(f.row).charAt(f.column-1);if(r=="")return null;var o=r.match(/([\(\[\{])|([\)\]\}])/);return o?o[1]?this.$findClosingBracket(o[1],f):this.$findOpeningBracket(o[2],f):null},this.getBracketRange=function(f){var a=this.getLine(f.row),r=!0,o,c=a.charAt(f.column-1),l=c&&c.match(/([\(\[\{])|([\)\]\}])/);if(l||(c=a.charAt(f.column),f={row:f.row,column:f.column+1},l=c&&c.match(/([\(\[\{])|([\)\]\}])/),r=!1),!l)return null;if(l[1]){var h=this.$findClosingBracket(l[1],f);if(!h)return null;o=P.fromPoints(f,h),r||(o.end.column++,o.start.column--),o.cursor=o.end}else{var h=this.$findOpeningBracket(l[2],f);if(!h)return null;o=P.fromPoints(h,f),r||(o.start.column++,o.end.column--),o.cursor=o.start}return o},this.getMatchingBracketRanges=function(f,a){var r=this.getLine(f.row),o=/([\(\[\{])|([\)\]\}])/,c=!a&&r.charAt(f.column-1),l=c&&c.match(o);if(l||(c=(a===void 0||a)&&r.charAt(f.column),f={row:f.row,column:f.column+1},l=c&&c.match(o)),!l)return null;var h=new P(f.row,f.column-1,f.row,f.column),d=l[1]?this.$findClosingBracket(l[1],f):this.$findOpeningBracket(l[2],f);if(!d)return[h];var g=new P(d.row,d.column,d.row,d.column+1);return[h,g]},this.$brackets={")":"(","(":")","]":"[","[":"]","{":"}","}":"{","<":">",">":"<"},this.$findOpeningBracket=function(f,a,r){var o=this.$brackets[f],c=1,l=new B(this,a.row,a.column),h=l.getCurrentToken();if(h||(h=l.stepForward()),!!h){r||(r=new RegExp("(\\.?"+h.type.replace(".","\\.").replace("rparen",".paren").replace(/\b(?:end)\b/,"(?:start|begin|end)").replace(/-close\b/,"-(close|open)")+")+"));for(var d=a.column-l.getCurrentTokenColumn()-2,g=h.value;;){for(;d>=0;){var _=g.charAt(d);if(_==o){if(c-=1,c==0)return{row:l.getCurrentTokenRow(),column:d+l.getCurrentTokenColumn()}}else _==f&&(c+=1);d-=1}do h=l.stepBackward();while(h&&!r.test(h.type));if(h==null)break;g=h.value,d=g.length-1}return null}},this.$findClosingBracket=function(f,a,r){var o=this.$brackets[f],c=1,l=new B(this,a.row,a.column),h=l.getCurrentToken();if(h||(h=l.stepForward()),!!h){r||(r=new RegExp("(\\.?"+h.type.replace(".","\\.").replace("lparen",".paren").replace(/\b(?:start|begin)\b/,"(?:start|begin|end)").replace(/-open\b/,"-(close|open)")+")+"));for(var d=a.column-l.getCurrentTokenColumn();;){for(var g=h.value,_=g.length;d<_;){var v=g.charAt(d);if(v==o){if(c-=1,c==0)return{row:l.getCurrentTokenRow(),column:d+l.getCurrentTokenColumn()}}else v==f&&(c+=1);d+=1}do h=l.stepForward();while(h&&!r.test(h.type));if(h==null)break;d=0}return null}},this.getMatchingTags=function(f){var a=new B(this,f.row,f.column),r=this.$findTagName(a);if(r){var o=a.stepBackward();return o.value==="<"?this.$findClosingTag(a,r):this.$findOpeningTag(a,r)}},this.$findTagName=function(f){var a=f.getCurrentToken(),r=!1,o=!1;if(a&&a.type.indexOf("tag-name")===-1)do o?a=f.stepBackward():a=f.stepForward(),a&&(a.value==="/>"?o=!0:a.type.indexOf("tag-name")!==-1&&(r=!0));while(a&&!r);return a},this.$findClosingTag=function(f,a){var r,o=a.value,c=a.value,l=0,h=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);a=f.stepForward();var d=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+a.value.length),g=!1;do if(r=a,a=f.stepForward(),a){if(a.value===">"&&!g){var _=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);g=!0}if(a.type.indexOf("tag-name")!==-1){if(o=a.value,c===o){if(r.value==="<")l++;else if(r.value==="")var y=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);else return}}}else if(c===o&&a.value==="/>"&&(l--,l<0))var v=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+2),M=v,y=M,_=new P(d.end.row,d.end.column,d.end.row,d.end.column+1)}while(a&&l>=0);if(h&&_&&v&&y&&d&&M)return{openTag:new P(h.start.row,h.start.column,_.end.row,_.end.column),closeTag:new P(v.start.row,v.start.column,y.end.row,y.end.column),openTagName:d,closeTagName:M}},this.$findOpeningTag=function(f,a){var r=f.getCurrentToken(),o=a.value,c=0,l=f.getCurrentTokenRow(),h=f.getCurrentTokenColumn(),d=h+2,g=new P(l,h,l,d);f.stepForward();var _=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+a.value.length);if(a=f.stepForward(),!(!a||a.value!==">")){var v=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);f.stepBackward(),f.stepBackward();do if(a=r,l=f.getCurrentTokenRow(),h=f.getCurrentTokenColumn(),d=h+a.value.length,r=f.stepBackward(),a){if(a.type.indexOf("tag-name")!==-1){if(o===a.value)if(r.value==="<"){if(c++,c>0){var M=new P(l,h,l,d),y=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1);do a=f.stepForward();while(a&&a.value!==">");var I=new P(f.getCurrentTokenRow(),f.getCurrentTokenColumn(),f.getCurrentTokenRow(),f.getCurrentTokenColumn()+1)}}else r.value===""){for(var w=0,x=r;x;){if(x.type.indexOf("tag-name")!==-1&&x.value===o){c--;break}else if(x.value==="<")break;x=f.stepBackward(),w++}for(var N=0;NA&&(this.$docRowCache.splice(A,F),this.$screenRowCache.splice(A,F))},R.prototype.$getRowCacheIndex=function(S,F){for(var A=0,E=S.length-1;A<=E;){var O=A+E>>1,k=S[O];if(F>k)A=O+1;else if(F=F));k++);return E=A[k],E?(E.index=k,E.start=O-E.value.length,E):null},R.prototype.setUndoManager=function(S){if(this.$undoManager=S,this.$informUndoManager&&this.$informUndoManager.cancel(),S){var F=this;S.addSession(this),this.$syncInformUndoManager=function(){F.$informUndoManager.cancel(),F.mergeUndoDeltas=!1},this.$informUndoManager=P.delayedCall(this.$syncInformUndoManager)}else this.$syncInformUndoManager=function(){}},R.prototype.markUndoGroup=function(){this.$syncInformUndoManager&&this.$syncInformUndoManager()},R.prototype.getUndoManager=function(){return this.$undoManager||this.$defaultUndoManager},R.prototype.getTabString=function(){return this.getUseSoftTabs()?P.stringRepeat(" ",this.getTabSize()):" "},R.prototype.setUseSoftTabs=function(S){this.setOption("useSoftTabs",S)},R.prototype.getUseSoftTabs=function(){return this.$useSoftTabs&&!this.$mode.$indentWithTabs},R.prototype.setTabSize=function(S){this.setOption("tabSize",S)},R.prototype.getTabSize=function(){return this.$tabSize},R.prototype.isTabStop=function(S){return this.$useSoftTabs&&S.column%this.$tabSize===0},R.prototype.setNavigateWithinSoftTabs=function(S){this.setOption("navigateWithinSoftTabs",S)},R.prototype.getNavigateWithinSoftTabs=function(){return this.$navigateWithinSoftTabs},R.prototype.setOverwrite=function(S){this.setOption("overwrite",S)},R.prototype.getOverwrite=function(){return this.$overwrite},R.prototype.toggleOverwrite=function(){this.setOverwrite(!this.$overwrite)},R.prototype.addGutterDecoration=function(S,F){this.$decorations[S]||(this.$decorations[S]=""),this.$decorations[S]+=" "+F,this._signal("changeBreakpoint",{})},R.prototype.removeGutterDecoration=function(S,F){this.$decorations[S]=(this.$decorations[S]||"").replace(" "+F,""),this._signal("changeBreakpoint",{})},R.prototype.getBreakpoints=function(){return this.$breakpoints},R.prototype.setBreakpoints=function(S){this.$breakpoints=[];for(var F=0;F0&&(E=!!A.charAt(F-1).match(this.tokenRe)),E||(E=!!A.charAt(F).match(this.tokenRe)),E)var O=this.tokenRe;else if(/^\s+$/.test(A.slice(F-1,F+1)))var O=/\s/;else var O=this.nonTokenRe;var k=F;if(k>0){do k--;while(k>=0&&A.charAt(k).match(O));k++}for(var H=F;HS&&(S=F.screenWidth)}),this.lineWidgetWidth=S},R.prototype.$computeWidth=function(S){if(this.$modified||S){if(this.$modified=!1,this.$useWrapMode)return this.screenWidth=this.$wrapLimit;for(var F=this.doc.getAllLines(),A=this.$rowLengthCache,E=0,O=0,k=this.$foldData[O],H=k?k.start.row:1/0,V=F.length,W=0;WH){if(W=k.end.row+1,W>=V)break;k=this.$foldData[O++],H=k?k.start.row:1/0}A[W]==null&&(A[W]=this.$getStringScreenWidth(F[W])[0]),A[W]>E&&(E=A[W])}this.screenWidth=E}},R.prototype.getLine=function(S){return this.doc.getLine(S)},R.prototype.getLines=function(S,F){return this.doc.getLines(S,F)},R.prototype.getLength=function(){return this.doc.getLength()},R.prototype.getTextRange=function(S){return this.doc.getTextRange(S||this.selection.getRange())},R.prototype.insert=function(S,F){return this.doc.insert(S,F)},R.prototype.remove=function(S){return this.doc.remove(S)},R.prototype.removeFullLines=function(S,F){return this.doc.removeFullLines(S,F)},R.prototype.undoChanges=function(S,F){if(S.length){this.$fromUndo=!0;for(var A=S.length-1;A!=-1;A--){var E=S[A];E.action=="insert"||E.action=="remove"?this.doc.revertDelta(E):E.folds&&this.addFolds(E.folds)}!F&&this.$undoSelect&&(S.selectionBefore?this.selection.fromJSON(S.selectionBefore):this.selection.setRange(this.$getUndoSelection(S,!0))),this.$fromUndo=!1}},R.prototype.redoChanges=function(S,F){if(S.length){this.$fromUndo=!0;for(var A=0;AS.end.column&&(k.start.column+=V),k.end.row==S.end.row&&k.end.column>S.end.column&&(k.end.column+=V)),H&&k.start.row>=S.end.row&&(k.start.row+=H,k.end.row+=H)}if(k.end=this.insert(k.start,E),O.length){var W=S.start,K=k.start,H=K.row-W.row,V=K.column-W.column;this.addFolds(O.map(function(J){return J=J.clone(),J.start.row==W.row&&(J.start.column+=V),J.end.row==W.row&&(J.end.column+=V),J.start.row+=H,J.end.row+=H,J}))}return k},R.prototype.indentRows=function(S,F,A){A=A.replace(/\t/g,this.getTabString());for(var E=S;E<=F;E++)this.doc.insertInLine({row:E,column:0},A)},R.prototype.outdentRows=function(S){for(var F=S.collapseRows(),A=new c(0,0,0,0),E=this.getTabSize(),O=F.start.row;O<=F.end.row;++O){var k=this.getLine(O);A.start.row=O,A.end.row=O;for(var H=0;H0){var E=this.getRowFoldEnd(F+A);if(E>this.doc.getLength()-1)return 0;var O=E-F}else{S=this.$clipRowToDocument(S),F=this.$clipRowToDocument(F);var O=F-S+1}var k=new c(S,0,F,Number.MAX_VALUE),H=this.getFoldsInRange(k).map(function(W){return W=W.clone(),W.start.row+=O,W.end.row+=O,W}),V=A==0?this.doc.getLines(S,F):this.doc.removeFullLines(S,F);return this.doc.insertFullLines(S+O,V),H.length&&this.addFolds(H),O},R.prototype.moveLinesUp=function(S,F){return this.$moveLines(S,F,-1)},R.prototype.moveLinesDown=function(S,F){return this.$moveLines(S,F,1)},R.prototype.duplicateLines=function(S,F){return this.$moveLines(S,F,0)},R.prototype.$clipRowToDocument=function(S){return Math.max(0,Math.min(S,this.doc.getLength()-1))},R.prototype.$clipColumnToRow=function(S,F){return F<0?0:Math.min(this.doc.getLine(S).length,F)},R.prototype.$clipPositionToDocument=function(S,F){if(F=Math.max(0,F),S<0)S=0,F=0;else{var A=this.doc.getLength();S>=A?(S=A-1,F=this.doc.getLine(A-1).length):F=Math.min(this.doc.getLine(S).length,F)}return{row:S,column:F}},R.prototype.$clipRangeToDocument=function(S){S.start.row<0?(S.start.row=0,S.start.column=0):S.start.column=this.$clipColumnToRow(S.start.row,S.start.column);var F=this.doc.getLength()-1;return S.end.row>F?(S.end.row=F,S.end.column=this.doc.getLine(F).length):S.end.column=this.$clipColumnToRow(S.end.row,S.end.column),S},R.prototype.setUseWrapMode=function(S){if(S!=this.$useWrapMode){if(this.$useWrapMode=S,this.$modified=!0,this.$resetRowCache(0),S){var F=this.getLength();this.$wrapData=Array(F),this.$updateWrapData(0,F-1)}this._signal("changeWrapMode")}},R.prototype.getUseWrapMode=function(){return this.$useWrapMode},R.prototype.setWrapLimitRange=function(S,F){(this.$wrapLimitRange.min!==S||this.$wrapLimitRange.max!==F)&&(this.$wrapLimitRange={min:S,max:F},this.$modified=!0,this.$bidiHandler.markAsDirty(),this.$useWrapMode&&this._signal("changeWrapMode"))},R.prototype.adjustWrapLimit=function(S,F){var A=this.$wrapLimitRange;A.max<0&&(A={min:F,max:F});var E=this.$constrainWrapLimit(S,A.min,A.max);return E!=this.$wrapLimit&&E>1?(this.$wrapLimit=E,this.$modified=!0,this.$useWrapMode&&(this.$updateWrapData(0,this.getLength()-1),this.$resetRowCache(0),this._signal("changeWrapLimit")),!0):!1},R.prototype.$constrainWrapLimit=function(S,F,A){return F&&(S=Math.max(F,S)),A&&(S=Math.min(A,S)),S},R.prototype.getWrapLimit=function(){return this.$wrapLimit},R.prototype.setWrapLimit=function(S){this.setWrapLimitRange(S,S)},R.prototype.getWrapLimitRange=function(){return{min:this.$wrapLimitRange.min,max:this.$wrapLimitRange.max}},R.prototype.$updateInternalDataOnChange=function(S){var F=this.$useWrapMode,A=S.action,E=S.start,O=S.end,k=E.row,H=O.row,V=H-k,W=null;if(this.$updating=!0,V!=0)if(A==="remove"){this[F?"$wrapData":"$rowLengthCache"].splice(k,V);var K=this.$foldData;W=this.getFoldsInRange(S),this.removeFolds(W);var Q=this.getFoldLine(O.row),ie=0;if(Q){Q.addRemoveChars(O.row,O.column,E.column-O.column),Q.shiftRow(-V);var J=this.getFoldLine(k);J&&J!==Q&&(J.merge(Q),Q=J),ie=K.indexOf(Q)+1}for(ie;ie=O.row&&Q.shiftRow(-V)}H=k}else{var Y=Array(V);Y.unshift(k,0);var z=F?this.$wrapData:this.$rowLengthCache;z.splice.apply(z,Y);var K=this.$foldData,Q=this.getFoldLine(k),ie=0;if(Q){var oe=Q.range.compareInside(E.row,E.column);oe==0?(Q=Q.split(E.row,E.column),Q&&(Q.shiftRow(V),Q.addRemoveChars(H,0,O.column-E.column))):oe==-1&&(Q.addRemoveChars(k,0,O.column-E.column),Q.shiftRow(V)),ie=K.indexOf(Q)+1}for(ie;ie=k&&Q.shiftRow(V)}}else{V=Math.abs(S.start.column-S.end.column),A==="remove"&&(W=this.getFoldsInRange(S),this.removeFolds(W),V=-V);var Q=this.getFoldLine(k);Q&&Q.addRemoveChars(k,E.column,V)}return F&&this.$wrapData.length!=this.doc.getLength()&&console.error("doc.getLength() and $wrapData.length have to be the same!"),this.$updating=!1,F?this.$updateWrapData(k,H):this.$updateRowLengthCache(k,H),W},R.prototype.$updateRowLengthCache=function(S,F,A){this.$rowLengthCache[S]=null,this.$rowLengthCache[F]=null},R.prototype.$updateWrapData=function(S,F){var A=this.doc.getAllLines(),E=this.getTabSize(),O=this.$wrapData,k=this.$wrapLimit,H,V,W=S;for(F=Math.min(F,A.length-1);W<=F;)V=this.getFoldLine(W,V),V?(H=[],V.walk(function(K,Q,ie,J){var Y;if(K!=null){Y=this.$getDisplayTokens(K,H.length),Y[0]=M;for(var z=1;zF-J;){var Y=k+F-J;if(S[Y-1]>=w&&S[Y]>=w){ie(Y);continue}if(S[Y]==M||S[Y]==y){for(Y;Y!=k-1&&S[Y]!=M;Y--);if(Y>k){ie(Y);continue}for(Y=k+F,Y;Y>2)),k-1);Y>z&&S[Y]z&&S[Y]z&&S[Y]==I;)Y--}else for(;Y>z&&S[Y]z){ie(++Y);continue}Y=k+F,S[Y]==v&&Y--,ie(Y-J)}return E},R.prototype.$getDisplayTokens=function(S,F){var A=[],E;F=F||0;for(var O=0;O39&&k<48||k>57&&k<64?A.push(I):k>=4352&&D(k)?A.push(_,v):A.push(_)}return A},R.prototype.$getStringScreenWidth=function(S,F,A){if(F==0)return[0,0];F==null&&(F=1/0),A=A||0;var E,O;for(O=0;O=4352&&D(E)?A+=2:A+=1,!(A>F));O++);return[A,O]},R.prototype.getRowLength=function(S){var F=1;return this.lineWidgets&&(F+=this.lineWidgets[S]&&this.lineWidgets[S].rowCount||0),!this.$useWrapMode||!this.$wrapData[S]?F:this.$wrapData[S].length+F},R.prototype.getRowLineCount=function(S){return!this.$useWrapMode||!this.$wrapData[S]?1:this.$wrapData[S].length+1},R.prototype.getRowWrapIndent=function(S){if(this.$useWrapMode){var F=this.screenToDocumentPosition(S,Number.MAX_VALUE),A=this.$wrapData[F.row];return A.length&&A[0]=0)var V=K[Q],O=this.$docRowCache[Q],J=S>K[ie-1];else var J=!ie;for(var Y=this.getLength()-1,z=this.getNextFoldLine(O),oe=z?z.start.row:1/0;V<=S&&(W=this.getRowLength(O),!(V+W>S||O>=Y));)V+=W,O++,O>oe&&(O=z.end.row+1,z=this.getNextFoldLine(O,z),oe=z?z.start.row:1/0),J&&(this.$docRowCache.push(O),this.$screenRowCache.push(V));if(z&&z.start.row<=O)E=this.getFoldDisplayLine(z),O=z.start.row;else{if(V+W<=S||O>Y)return{row:Y,column:this.getLine(Y).length};E=this.getLine(O),z=null}var he=0,de=Math.floor(S-V);if(this.$useWrapMode){var fe=this.$wrapData[O];fe&&(H=fe[de],de>0&&fe.length&&(he=fe.indent,k=fe[de-1]||fe[fe.length-1],E=E.substring(k)))}return A!==void 0&&this.$bidiHandler.isBidiRow(V+de,O,de)&&(F=this.$bidiHandler.offsetToCol(A)),k+=this.$getStringScreenWidth(E,F-he)[1],this.$useWrapMode&&k>=H&&(k=H-1),z?z.idxToPosition(k):{row:O,column:k}},R.prototype.documentToScreenPosition=function(S,F){if(typeof F>"u")var A=this.$clipPositionToDocument(S.row,S.column);else A=this.$clipPositionToDocument(S,F);S=A.row,F=A.column;var E=0,O=null,k=null;k=this.getFoldAt(S,F,1),k&&(S=k.start.row,F=k.start.column);var H,V=0,W=this.$docRowCache,K=this.$getRowCacheIndex(W,S),Q=W.length;if(Q&&K>=0)var V=W[K],E=this.$screenRowCache[K],ie=S>W[Q-1];else var ie=!Q;for(var J=this.getNextFoldLine(V),Y=J?J.start.row:1/0;V=Y){if(H=J.end.row+1,H>S)break;J=this.getNextFoldLine(H,J),Y=J?J.start.row:1/0}else H=V+1;E+=this.getRowLength(V),V=H,ie&&(this.$docRowCache.push(V),this.$screenRowCache.push(E))}var z="";J&&V>=Y?(z=this.getFoldDisplayLine(J,S,F),O=J.start.row):(z=this.getLine(S).substring(0,F),O=S);var oe=0;if(this.$useWrapMode){var he=this.$wrapData[O];if(he){for(var de=0;z.length>=he[de];)E++,de++;z=z.substring(he[de-1]||0,z.length),oe=de>0?he.indent:0}}return this.lineWidgets&&this.lineWidgets[V]&&this.lineWidgets[V].rowsAbove&&(E+=this.lineWidgets[V].rowsAbove),{row:E,column:oe+this.$getStringScreenWidth(z)[0]}},R.prototype.documentToScreenColumn=function(S,F){return this.documentToScreenPosition(S,F).column},R.prototype.documentToScreenRow=function(S,F){return this.documentToScreenPosition(S,F).row},R.prototype.getScreenLength=function(){var S=0,F=null;if(this.$useWrapMode)for(var O=this.$wrapData.length,k=0,E=0,F=this.$foldData[E++],H=F?F.start.row:1/0;kH&&(k=F.end.row+1,F=this.$foldData[E++],H=F?F.start.row:1/0)}else{S=this.getLength();for(var A=this.$foldData,E=0;EA));k++);return[E,k]})},R.prototype.destroy=function(){this.destroyed||(this.bgTokenizer.setDocument(null),this.bgTokenizer.cleanup(),this.destroyed=!0),this.$stopWorker(),this.removeAllListeners(),this.doc&&this.doc.off("change",this.$onChange),this.selection.detach()},R}();g.$uid=0,g.prototype.$modes=f.$modes,g.prototype.getValue=g.prototype.toString,g.prototype.$defaultUndoManager={undo:function(){},redo:function(){},hasUndo:function(){},hasRedo:function(){},reset:function(){},add:function(){},addSelection:function(){},startNewGroup:function(){},addSession:function(){}},g.prototype.$overwrite=!1,g.prototype.$mode=null,g.prototype.$modeId=null,g.prototype.$scrollTop=0,g.prototype.$scrollLeft=0,g.prototype.$wrapLimit=80,g.prototype.$useWrapMode=!1,g.prototype.$wrapLimitRange={min:null,max:null},g.prototype.lineWidgets=null,g.prototype.isFullWidth=D,B.implement(g.prototype,a);var _=1,v=2,M=3,y=4,I=9,w=10,x=11,N=12;function D(R){return R<4352?!1:R>=4352&&R<=4447||R>=4515&&R<=4519||R>=4602&&R<=4607||R>=9001&&R<=9002||R>=11904&&R<=11929||R>=11931&&R<=12019||R>=12032&&R<=12245||R>=12272&&R<=12283||R>=12288&&R<=12350||R>=12353&&R<=12438||R>=12441&&R<=12543||R>=12549&&R<=12589||R>=12593&&R<=12686||R>=12688&&R<=12730||R>=12736&&R<=12771||R>=12784&&R<=12830||R>=12832&&R<=12871||R>=12880&&R<=13054||R>=13056&&R<=19903||R>=19968&&R<=42124||R>=42128&&R<=42182||R>=43360&&R<=43388||R>=44032&&R<=55203||R>=55216&&R<=55238||R>=55243&&R<=55291||R>=63744&&R<=64255||R>=65040&&R<=65049||R>=65072&&R<=65106||R>=65108&&R<=65126||R>=65128&&R<=65131||R>=65281&&R<=65376||R>=65504&&R<=65510}s("./edit_session/folding").Folding.call(g.prototype),s("./edit_session/bracket_match").BracketMatch.call(g.prototype),f.defineOptions(g.prototype,"session",{wrap:{set:function(R){if(!R||R=="off"?R=!1:R=="free"?R=!0:R=="printMargin"?R=-1:typeof R=="string"&&(R=parseInt(R,10)||!1),this.$wrap!=R)if(this.$wrap=R,!R)this.setUseWrapMode(!1);else{var S=typeof R=="number"?R:null;this.setWrapLimitRange(S,S),this.setUseWrapMode(!0)}},get:function(){return this.getUseWrapMode()?this.$wrap==-1?"printMargin":this.getWrapLimitRange().min?this.$wrap:"free":"off"},handlesSet:!0},wrapMethod:{set:function(R){R=R=="auto"?this.$mode.type!="text":R!="text",R!=this.$wrapAsCode&&(this.$wrapAsCode=R,this.$useWrapMode&&(this.$useWrapMode=!1,this.setUseWrapMode(!0)))},initialValue:"auto"},indentedSoftWrap:{set:function(){this.$useWrapMode&&(this.$useWrapMode=!1,this.setUseWrapMode(!0))},initialValue:!0},firstLineNumber:{set:function(){this._signal("changeBreakpoint")},initialValue:1},useWorker:{set:function(R){this.$useWorker=R,this.$stopWorker(),R&&this.$startWorker()},initialValue:!0},useSoftTabs:{initialValue:!0},tabSize:{set:function(R){R=parseInt(R),R>0&&this.$tabSize!==R&&(this.$modified=!0,this.$rowLengthCache=[],this.$tabSize=R,this._signal("changeTabSize"))},initialValue:4,handlesSet:!0},navigateWithinSoftTabs:{initialValue:!1},foldStyle:{set:function(R){this.setFoldStyle(R)},handlesSet:!0},overwrite:{set:function(R){this._signal("changeOverwrite")},initialValue:!1},newLineMode:{set:function(R){this.doc.setNewLineMode(R)},get:function(){return this.doc.getNewLineMode()},handlesSet:!0},mode:{set:function(R){this.setMode(R)},get:function(){return this.$modeId},handlesSet:!0}}),p.EditSession=g}),ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"],function(s,p,m){var B=s("./lib/lang"),P=s("./lib/oop"),C=s("./range").Range,f=function(){function r(){this.$options={}}return r.prototype.set=function(o){return P.mixin(this.$options,o),this},r.prototype.getOptions=function(){return B.copyObject(this.$options)},r.prototype.setOptions=function(o){this.$options=o},r.prototype.find=function(o){var c=this.$options,l=this.$matchIterator(o,c);if(!l)return!1;var h=null;return l.forEach(function(d,g,_,v){return h=new C(d,g,_,v),g==v&&c.start&&c.start.start&&c.skipCurrent!=!1&&h.isEqual(c.start)?(h=null,!1):!0}),h},r.prototype.findAll=function(o){var c=this.$options;if(!c.needle)return[];this.$assembleRegExp(c);var l=c.range,h=l?o.getLines(l.start.row,l.end.row):o.doc.getAllLines(),d=[],g=c.re;if(c.$isMultiLine){var _=g.length,v=h.length-_,M;e:for(var y=g.offset||0;y<=v;y++){for(var I=0;I<_;I++)if(h[y+I].search(g[I])==-1)continue e;var w=h[y],x=h[y+_-1],N=w.length-w.match(g[0])[0].length,D=x.match(g[_-1])[0].length;M&&M.end.row===y&&M.end.column>N||(d.push(M=new C(y,N,y+_-1,D)),_>2&&(y=y+_-2))}}else for(var R=0;RE&&d[I].end.row==O;)I--;for(d=d.slice(R,I+1),R=0,I=d.length;R=v;N--)if(b(N,Number.MAX_VALUE,x))return;if(c.wrap!=!1){for(N=k,v=_.row;N>=v;N--)if(b(N,Number.MAX_VALUE,x))return}}};else var I=function(N){var D=_.row;if(!b(D,_.column,N)){for(D=D+1;D<=k;D++)if(b(D,0,N))return;if(c.wrap!=!1){for(D=v,k=_.row;D<=k;D++)if(b(D,0,N))return}}};if(c.$isMultiLine)var S=l.length,b=function(x,N,D){var R=h?x-S+1:x;if(!(R<0||R+S>o.getLength())){var w=o.getLine(R),F=w.search(l[0]);if(!(!h&&FN)&&D(R,F,R+S-1,T))return!0}}};else if(h)var b=function(N,D,R){var w=o.getLine(N),F=[],A,T=0;for(l.lastIndex=0;A=l.exec(w);){var L=A[0].length;if(T=A.index,!L){if(T>=w.length)break;l.lastIndex=T+=1}if(A.index+L>D)break;F.push(A.index,L)}for(var O=F.length-1;O>=0;O-=2){var H=F[O-1],L=F[O];if(R(N,H,N,H+L))return!0}};else var b=function(N,D,R){var w=o.getLine(N),F,A;for(l.lastIndex=D;A=l.exec(w);){var T=A[0].length;if(F=A.index,R(N,F,N,F+T))return!0;if(!T&&(l.lastIndex=F+=1,F>=w.length))return!1}};return{forEach:I}},s}();function a(s,o){function c(l){return/\w/.test(l)||o.regExp?"\\b":""}return c(s[0])+s+c(s[s.length-1])}p.Search=f}),ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(r,p,m){var B=r("../lib/keys"),P=r("../lib/useragent"),C=B.KEY_MODS;function f(s,o){this.platform=o||(P.isMac?"mac":"win"),this.commands={},this.commandKeyBinding={},this.addCommands(s),this.$singleCommand=!0}function a(s,o){f.call(this,s,o),this.$singleCommand=!1}a.prototype=f.prototype,function(){this.addCommand=function(o){this.commands[o.name]&&this.removeCommand(o),this.commands[o.name]=o,o.bindKey&&this._buildKeyHash(o)},this.removeCommand=function(o,c){var l=o&&(typeof o=="string"?o:o.name);o=this.commands[l],c||delete this.commands[l];var h=this.commandKeyBinding;for(var d in h){var g=h[d];if(g==o)delete h[d];else if(Array.isArray(g)){var _=g.indexOf(o);_!=-1&&(g.splice(_,1),g.length==1&&(h[d]=g[0]))}}},this.bindKey=function(o,c,l){if(typeof o=="object"&&o&&(l==null&&(l=o.position),o=o[this.platform]),!!o){if(typeof c=="function")return this.addCommand({exec:c,bindKey:o,name:c.name||o});o.split("|").forEach(function(h){var d="";if(h.indexOf(" ")!=-1){var g=h.split(/\s+/);h=g.pop(),g.forEach(function(k){var I=this.parseKeys(k),S=C[I.hashId]+I.key;d+=(d?" ":"")+S,this._addCommandToBinding(d,"chainKeys")},this),d+=" "}var _=this.parseKeys(h),v=C[_.hashId]+_.key;this._addCommandToBinding(d+v,c,l)},this)}};function s(o){return typeof o=="object"&&o.bindKey&&o.bindKey.position||(o.isDefault?-100:0)}this._addCommandToBinding=function(o,c,l){var h=this.commandKeyBinding,d;if(!c)delete h[o];else if(!h[o]||this.$singleCommand)h[o]=c;else{Array.isArray(h[o])?(d=h[o].indexOf(c))!=-1&&h[o].splice(d,1):h[o]=[h[o]],typeof l!="number"&&(l=s(c));var g=h[o];for(d=0;dl)break}g.splice(d,0,c)}},this.addCommands=function(o){o&&Object.keys(o).forEach(function(c){var l=o[c];if(l){if(typeof l=="string")return this.bindKey(l,c);typeof l=="function"&&(l={exec:l}),typeof l=="object"&&(l.name||(l.name=c),this.addCommand(l))}},this)},this.removeCommands=function(o){Object.keys(o).forEach(function(c){this.removeCommand(o[c])},this)},this.bindKeys=function(o){Object.keys(o).forEach(function(c){this.bindKey(c,o[c])},this)},this._buildKeyHash=function(o){this.bindKey(o.bindKey,o)},this.parseKeys=function(o){var c=o.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(v){return v}),l=c.pop(),h=B[l];if(B.FUNCTION_KEYS[h])l=B.FUNCTION_KEYS[h].toLowerCase();else if(c.length){if(c.length==1&&c[0]=="shift")return{key:l.toUpperCase(),hashId:-1}}else return{key:l,hashId:-1};for(var d=0,g=c.length;g--;){var _=B.KEY_MODS[c[g]];if(_==null)return typeof console<"u"&&console.error("invalid modifier "+c[g]+" in "+o),!1;d|=_}return{key:l,hashId:d}},this.findKeyCommand=function(c,l){var h=C[c]+l;return this.commandKeyBinding[h]},this.handleKeyboard=function(o,c,l,h){if(!(h<0)){var d=C[c]+l,g=this.commandKeyBinding[d];return o.$keyChain&&(o.$keyChain+=" "+d,g=this.commandKeyBinding[o.$keyChain]||g),g&&(g=="chainKeys"||g[g.length-1]=="chainKeys")?(o.$keyChain=o.$keyChain||d,{command:"null"}):(o.$keyChain&&((!c||c==4)&&l.length==1?o.$keyChain=o.$keyChain.slice(0,-d.length-1):(c==-1||h>0)&&(o.$keyChain="")),{command:g})}},this.getStatusText=function(o,c){return c.$keyChain||""}}.call(f.prototype),p.HashHandler=f,p.MultiHashHandler=a}),ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"],function(r,p,m){var B=this&&this.__extends||function(){var s=function(o,c){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,h){l.__proto__=h}||function(l,h){for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&(l[d]=h[d])},s(o,c)};return function(o,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");s(o,c);function l(){this.constructor=o}o.prototype=c===null?Object.create(c):(l.prototype=c.prototype,new l)}}(),P=r("../lib/oop"),C=r("../keyboard/hash_handler").MultiHashHandler,f=r("../lib/event_emitter").EventEmitter,a=function(s){B(o,s);function o(c,l){var h=s.call(this,l,c)||this;return h.byName=h.commands,h.setDefaultHandler("exec",function(d){return d.args?d.command.exec(d.editor,d.args,d.event,!1):d.command.exec(d.editor,{},d.event,!0)}),h}return o.prototype.exec=function(c,l,h){if(Array.isArray(c)){for(var d=c.length;d--;)if(this.exec(c[d],l,h))return!0;return!1}if(typeof c=="string"&&(c=this.commands[c]),!c||l&&l.$readOnly&&!c.readOnly||this.$checkCommandState!=!1&&c.isAvailable&&!c.isAvailable(l))return!1;var g={editor:l,command:c,args:h};return g.returnValue=this._emit("exec",g),this._signal("afterExec",g),g.returnValue!==!1},o.prototype.toggleRecording=function(c){if(!this.$inReplay)return c&&c._emit("changeStatus"),this.recording?(this.macro.pop(),this.off("exec",this.$addCommandToMacro),this.macro.length||(this.macro=this.oldMacro),this.recording=!1):(this.$addCommandToMacro||(this.$addCommandToMacro=function(l){this.macro.push([l.command,l.args])}.bind(this)),this.oldMacro=this.macro,this.macro=[],this.on("exec",this.$addCommandToMacro),this.recording=!0)},o.prototype.replay=function(c){if(!(this.$inReplay||!this.macro)){if(this.recording)return this.toggleRecording(c);try{this.$inReplay=!0,this.macro.forEach(function(l){typeof l=="string"?this.exec(l,c):this.exec(l[0],c,l[1])},this)}finally{this.$inReplay=!1}}},o.prototype.trimMacro=function(c){return c.map(function(l){return typeof l[0]!="string"&&(l[0]=l[0].name),l[1]||(l=l[0]),l})},o}(C);P.implement(a.prototype,f),p.CommandManager=a}),ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"],function(r,p,m){var B=r("../lib/lang"),P=r("../config"),C=r("../range").Range;function f(s,o){return{win:s,mac:o}}p.commands=[{name:"showSettingsMenu",description:"Show settings menu",bindKey:f("Ctrl-,","Command-,"),exec:function(s){P.loadModule("ace/ext/settings_menu",function(o){o.init(s),s.showSettingsMenu()})},readOnly:!0},{name:"goToNextError",description:"Go to next error",bindKey:f("Alt-E","F4"),exec:function(s){P.loadModule("ace/ext/error_marker",function(o){o.showErrorMarker(s,1)})},scrollIntoView:"animate",readOnly:!0},{name:"goToPreviousError",description:"Go to previous error",bindKey:f("Alt-Shift-E","Shift-F4"),exec:function(s){P.loadModule("ace/ext/error_marker",function(o){o.showErrorMarker(s,-1)})},scrollIntoView:"animate",readOnly:!0},{name:"selectall",description:"Select all",bindKey:f("Ctrl-A","Command-A"),exec:function(s){s.selectAll()},readOnly:!0},{name:"centerselection",description:"Center selection",bindKey:f(null,"Ctrl-L"),exec:function(s){s.centerSelection()},readOnly:!0},{name:"gotoline",description:"Go to line...",bindKey:f("Ctrl-L","Command-L"),exec:function(s,o){typeof o=="number"&&!isNaN(o)&&s.gotoLine(o),s.prompt({$type:"gotoLine"})},readOnly:!0},{name:"fold",bindKey:f("Alt-L|Ctrl-F1","Command-Alt-L|Command-F1"),exec:function(s){s.session.toggleFold(!1)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"unfold",bindKey:f("Alt-Shift-L|Ctrl-Shift-F1","Command-Alt-Shift-L|Command-Shift-F1"),exec:function(s){s.session.toggleFold(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleFoldWidget",description:"Toggle fold widget",bindKey:f("F2","F2"),exec:function(s){s.session.toggleFoldWidget()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleParentFoldWidget",description:"Toggle parent fold widget",bindKey:f("Alt-F2","Alt-F2"),exec:function(s){s.session.toggleFoldWidget(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"foldall",description:"Fold all",bindKey:f(null,"Ctrl-Command-Option-0"),exec:function(s){s.session.foldAll()},scrollIntoView:"center",readOnly:!0},{name:"foldAllComments",description:"Fold all comments",bindKey:f(null,"Ctrl-Command-Option-0"),exec:function(s){s.session.foldAllComments()},scrollIntoView:"center",readOnly:!0},{name:"foldOther",description:"Fold other",bindKey:f("Alt-0","Command-Option-0"),exec:function(s){s.session.foldAll(),s.session.unfold(s.selection.getAllRanges())},scrollIntoView:"center",readOnly:!0},{name:"unfoldall",description:"Unfold all",bindKey:f("Alt-Shift-0","Command-Option-Shift-0"),exec:function(s){s.session.unfold()},scrollIntoView:"center",readOnly:!0},{name:"findnext",description:"Find next",bindKey:f("Ctrl-K","Command-G"),exec:function(s){s.findNext()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"findprevious",description:"Find previous",bindKey:f("Ctrl-Shift-K","Command-Shift-G"),exec:function(s){s.findPrevious()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"selectOrFindNext",description:"Select or find next",bindKey:f("Alt-K","Ctrl-G"),exec:function(s){s.selection.isEmpty()?s.selection.selectWord():s.findNext()},readOnly:!0},{name:"selectOrFindPrevious",description:"Select or find previous",bindKey:f("Alt-Shift-K","Ctrl-Shift-G"),exec:function(s){s.selection.isEmpty()?s.selection.selectWord():s.findPrevious()},readOnly:!0},{name:"find",description:"Find",bindKey:f("Ctrl-F","Command-F"),exec:function(s){P.loadModule("ace/ext/searchbox",function(o){o.Search(s)})},readOnly:!0},{name:"overwrite",description:"Overwrite",bindKey:"Insert",exec:function(s){s.toggleOverwrite()},readOnly:!0},{name:"selecttostart",description:"Select to start",bindKey:f("Ctrl-Shift-Home","Command-Shift-Home|Command-Shift-Up"),exec:function(s){s.getSelection().selectFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotostart",description:"Go to start",bindKey:f("Ctrl-Home","Command-Home|Command-Up"),exec:function(s){s.navigateFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectup",description:"Select up",bindKey:f("Shift-Up","Shift-Up|Ctrl-Shift-P"),exec:function(s){s.getSelection().selectUp()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golineup",description:"Go line up",bindKey:f("Up","Up|Ctrl-P"),exec:function(s,o){s.navigateUp(o.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttoend",description:"Select to end",bindKey:f("Ctrl-Shift-End","Command-Shift-End|Command-Shift-Down"),exec:function(s){s.getSelection().selectFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotoend",description:"Go to end",bindKey:f("Ctrl-End","Command-End|Command-Down"),exec:function(s){s.navigateFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectdown",description:"Select down",bindKey:f("Shift-Down","Shift-Down|Ctrl-Shift-N"),exec:function(s){s.getSelection().selectDown()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golinedown",description:"Go line down",bindKey:f("Down","Down|Ctrl-N"),exec:function(s,o){s.navigateDown(o.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordleft",description:"Select word left",bindKey:f("Ctrl-Shift-Left","Option-Shift-Left"),exec:function(s){s.getSelection().selectWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordleft",description:"Go to word left",bindKey:f("Ctrl-Left","Option-Left"),exec:function(s){s.navigateWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolinestart",description:"Select to line start",bindKey:f("Alt-Shift-Left","Command-Shift-Left|Ctrl-Shift-A"),exec:function(s){s.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolinestart",description:"Go to line start",bindKey:f("Alt-Left|Home","Command-Left|Home|Ctrl-A"),exec:function(s){s.navigateLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectleft",description:"Select left",bindKey:f("Shift-Left","Shift-Left|Ctrl-Shift-B"),exec:function(s){s.getSelection().selectLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoleft",description:"Go to left",bindKey:f("Left","Left|Ctrl-B"),exec:function(s,o){s.navigateLeft(o.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordright",description:"Select word right",bindKey:f("Ctrl-Shift-Right","Option-Shift-Right"),exec:function(s){s.getSelection().selectWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordright",description:"Go to word right",bindKey:f("Ctrl-Right","Option-Right"),exec:function(s){s.navigateWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolineend",description:"Select to line end",bindKey:f("Alt-Shift-Right","Command-Shift-Right|Shift-End|Ctrl-Shift-E"),exec:function(s){s.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolineend",description:"Go to line end",bindKey:f("Alt-Right|End","Command-Right|End|Ctrl-E"),exec:function(s){s.navigateLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectright",description:"Select right",bindKey:f("Shift-Right","Shift-Right"),exec:function(s){s.getSelection().selectRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoright",description:"Go to right",bindKey:f("Right","Right|Ctrl-F"),exec:function(s,o){s.navigateRight(o.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectpagedown",description:"Select page down",bindKey:"Shift-PageDown",exec:function(s){s.selectPageDown()},readOnly:!0},{name:"pagedown",description:"Page down",bindKey:f(null,"Option-PageDown"),exec:function(s){s.scrollPageDown()},readOnly:!0},{name:"gotopagedown",description:"Go to page down",bindKey:f("PageDown","PageDown|Ctrl-V"),exec:function(s){s.gotoPageDown()},readOnly:!0},{name:"selectpageup",description:"Select page up",bindKey:"Shift-PageUp",exec:function(s){s.selectPageUp()},readOnly:!0},{name:"pageup",description:"Page up",bindKey:f(null,"Option-PageUp"),exec:function(s){s.scrollPageUp()},readOnly:!0},{name:"gotopageup",description:"Go to page up",bindKey:"PageUp",exec:function(s){s.gotoPageUp()},readOnly:!0},{name:"scrollup",description:"Scroll up",bindKey:f("Ctrl-Up",null),exec:function(s){s.renderer.scrollBy(0,-2*s.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"scrolldown",description:"Scroll down",bindKey:f("Ctrl-Down",null),exec:function(s){s.renderer.scrollBy(0,2*s.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"selectlinestart",description:"Select line start",bindKey:"Shift-Home",exec:function(s){s.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectlineend",description:"Select line end",bindKey:"Shift-End",exec:function(s){s.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"togglerecording",description:"Toggle recording",bindKey:f("Ctrl-Alt-E","Command-Option-E"),exec:function(s){s.commands.toggleRecording(s)},readOnly:!0},{name:"replaymacro",description:"Replay macro",bindKey:f("Ctrl-Shift-E","Command-Shift-E"),exec:function(s){s.commands.replay(s)},readOnly:!0},{name:"jumptomatching",description:"Jump to matching",bindKey:f("Ctrl-\\|Ctrl-P","Command-\\"),exec:function(s){s.jumpToMatching()},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"selecttomatching",description:"Select to matching",bindKey:f("Ctrl-Shift-\\|Ctrl-Shift-P","Command-Shift-\\"),exec:function(s){s.jumpToMatching(!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"expandToMatching",description:"Expand to matching",bindKey:f("Ctrl-Shift-M","Ctrl-Shift-M"),exec:function(s){s.jumpToMatching(!0,!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"passKeysToBrowser",description:"Pass keys to browser",bindKey:f(null,null),exec:function(){},passEvent:!0,readOnly:!0},{name:"copy",description:"Copy",exec:function(s){},readOnly:!0},{name:"cut",description:"Cut",exec:function(s){var o=s.$copyWithEmptySelection&&s.selection.isEmpty(),c=o?s.selection.getLineRange():s.selection.getRange();s._emit("cut",c),c.isEmpty()||s.session.remove(c),s.clearSelection()},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"paste",description:"Paste",exec:function(s,o){s.$handlePaste(o)},scrollIntoView:"cursor"},{name:"removeline",description:"Remove line",bindKey:f("Ctrl-D","Command-D"),exec:function(s){s.removeLines()},scrollIntoView:"cursor",multiSelectAction:"forEachLine"},{name:"duplicateSelection",description:"Duplicate selection",bindKey:f("Ctrl-Shift-D","Command-Shift-D"),exec:function(s){s.duplicateSelection()},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"sortlines",description:"Sort lines",bindKey:f("Ctrl-Alt-S","Command-Alt-S"),exec:function(s){s.sortLines()},scrollIntoView:"selection",multiSelectAction:"forEachLine"},{name:"togglecomment",description:"Toggle comment",bindKey:f("Ctrl-/","Command-/"),exec:function(s){s.toggleCommentLines()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"toggleBlockComment",description:"Toggle block comment",bindKey:f("Ctrl-Shift-/","Command-Shift-/"),exec:function(s){s.toggleBlockComment()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"modifyNumberUp",description:"Modify number up",bindKey:f("Ctrl-Shift-Up","Alt-Shift-Up"),exec:function(s){s.modifyNumber(1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"modifyNumberDown",description:"Modify number down",bindKey:f("Ctrl-Shift-Down","Alt-Shift-Down"),exec:function(s){s.modifyNumber(-1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"replace",description:"Replace",bindKey:f("Ctrl-H","Command-Option-F"),exec:function(s){P.loadModule("ace/ext/searchbox",function(o){o.Search(s,!0)})}},{name:"undo",description:"Undo",bindKey:f("Ctrl-Z","Command-Z"),exec:function(s){s.undo()}},{name:"redo",description:"Redo",bindKey:f("Ctrl-Shift-Z|Ctrl-Y","Command-Shift-Z|Command-Y"),exec:function(s){s.redo()}},{name:"copylinesup",description:"Copy lines up",bindKey:f("Alt-Shift-Up","Command-Option-Up"),exec:function(s){s.copyLinesUp()},scrollIntoView:"cursor"},{name:"movelinesup",description:"Move lines up",bindKey:f("Alt-Up","Option-Up"),exec:function(s){s.moveLinesUp()},scrollIntoView:"cursor"},{name:"copylinesdown",description:"Copy lines down",bindKey:f("Alt-Shift-Down","Command-Option-Down"),exec:function(s){s.copyLinesDown()},scrollIntoView:"cursor"},{name:"movelinesdown",description:"Move lines down",bindKey:f("Alt-Down","Option-Down"),exec:function(s){s.moveLinesDown()},scrollIntoView:"cursor"},{name:"del",description:"Delete",bindKey:f("Delete","Delete|Ctrl-D|Shift-Delete"),exec:function(s){s.remove("right")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"backspace",description:"Backspace",bindKey:f("Shift-Backspace|Backspace","Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"),exec:function(s){s.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"cut_or_delete",description:"Cut or delete",bindKey:f("Shift-Delete",null),exec:function(s){if(s.selection.isEmpty())s.remove("left");else return!1},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolinestart",description:"Remove to line start",bindKey:f("Alt-Backspace","Command-Backspace"),exec:function(s){s.removeToLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolineend",description:"Remove to line end",bindKey:f("Alt-Delete","Ctrl-K|Command-Delete"),exec:function(s){s.removeToLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolinestarthard",description:"Remove to line start hard",bindKey:f("Ctrl-Shift-Backspace",null),exec:function(s){var o=s.selection.getRange();o.start.column=0,s.session.remove(o)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolineendhard",description:"Remove to line end hard",bindKey:f("Ctrl-Shift-Delete",null),exec:function(s){var o=s.selection.getRange();o.end.column=Number.MAX_VALUE,s.session.remove(o)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordleft",description:"Remove word left",bindKey:f("Ctrl-Backspace","Alt-Backspace|Ctrl-Alt-Backspace"),exec:function(s){s.removeWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordright",description:"Remove word right",bindKey:f("Ctrl-Delete","Alt-Delete"),exec:function(s){s.removeWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"outdent",description:"Outdent",bindKey:f("Shift-Tab","Shift-Tab"),exec:function(s){s.blockOutdent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"indent",description:"Indent",bindKey:f("Tab","Tab"),exec:function(s){s.indent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"blockoutdent",description:"Block outdent",bindKey:f("Ctrl-[","Ctrl-["),exec:function(s){s.blockOutdent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"blockindent",description:"Block indent",bindKey:f("Ctrl-]","Ctrl-]"),exec:function(s){s.blockIndent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"insertstring",description:"Insert string",exec:function(s,o){s.insert(o)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"inserttext",description:"Insert text",exec:function(s,o){s.insert(B.stringRepeat(o.text||"",o.times||1))},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"splitline",description:"Split line",bindKey:f(null,"Ctrl-O"),exec:function(s){s.splitLine()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"transposeletters",description:"Transpose letters",bindKey:f("Alt-Shift-X","Ctrl-T"),exec:function(s){s.transposeLetters()},multiSelectAction:function(s){s.transposeSelections(1)},scrollIntoView:"cursor"},{name:"touppercase",description:"To uppercase",bindKey:f("Ctrl-U","Ctrl-U"),exec:function(s){s.toUpperCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"tolowercase",description:"To lowercase",bindKey:f("Ctrl-Shift-U","Ctrl-Shift-U"),exec:function(s){s.toLowerCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"autoindent",description:"Auto Indent",bindKey:f(null,null),exec:function(s){s.autoIndent()},multiSelectAction:"forEachLine",scrollIntoView:"animate"},{name:"expandtoline",description:"Expand to line",bindKey:f("Ctrl-Shift-L","Command-Shift-L"),exec:function(s){var o=s.selection.getRange();o.start.column=o.end.column=0,o.end.row++,s.selection.setRange(o,!1)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"openlink",bindKey:f("Ctrl+F3","F3"),exec:function(s){s.openLink()}},{name:"joinlines",description:"Join lines",bindKey:f(null,null),exec:function(s){for(var o=s.selection.isBackwards(),c=o?s.selection.getSelectionLead():s.selection.getSelectionAnchor(),l=o?s.selection.getSelectionAnchor():s.selection.getSelectionLead(),h=s.session.doc.getLine(c.row).length,d=s.session.doc.getTextRange(s.selection.getRange()),g=d.replace(/\n\s*/," ").length,_=s.session.doc.getLine(c.row),v=c.row+1;v<=l.row+1;v++){var k=B.stringTrimLeft(B.stringTrimRight(s.session.doc.getLine(v)));k.length!==0&&(k=" "+k),_+=k}l.row+10?(s.selection.moveCursorTo(c.row,c.column),s.selection.selectTo(c.row,c.column+g)):(h=s.session.doc.getLine(c.row).length>h?h+1:h,s.selection.moveCursorTo(c.row,h))},multiSelectAction:"forEach",readOnly:!0},{name:"invertSelection",description:"Invert selection",bindKey:f(null,null),exec:function(s){var o=s.session.doc.getLength()-1,c=s.session.doc.getLine(o).length,l=s.selection.rangeList.ranges,h=[];l.length<1&&(l=[s.selection.getRange()]);for(var d=0;da[s].column&&s++,l.unshift(s,0),a.splice.apply(a,l),this.$updateRows()}}},C.prototype.$updateRows=function(){var f=this.session.lineWidgets;if(f){var a=!0;f.forEach(function(s,o){if(s)for(a=!1,s.row=o;s.$oldWidget;)s.$oldWidget.row=o,s=s.$oldWidget}),a&&(this.session.lineWidgets=null)}},C.prototype.$registerLineWidget=function(f){this.session.lineWidgets||(this.session.lineWidgets=new Array(this.session.getLength()));var a=this.session.lineWidgets[f.row];return a&&(f.$oldWidget=a,a.el&&a.el.parentNode&&(a.el.parentNode.removeChild(a.el),a._inDocument=!1)),this.session.lineWidgets[f.row]=f,f},C.prototype.addLineWidget=function(f){if(this.$registerLineWidget(f),f.session=this.session,!this.editor)return f;var a=this.editor.renderer;f.html&&!f.el&&(f.el=B.createElement("div"),f.el.innerHTML=f.html),f.text&&!f.el&&(f.el=B.createElement("div"),f.el.textContent=f.text),f.el&&(B.addCssClass(f.el,"ace_lineWidgetContainer"),f.className&&B.addCssClass(f.el,f.className),f.el.style.position="absolute",f.el.style.zIndex=5,a.container.appendChild(f.el),f._inDocument=!0,f.coverGutter||(f.el.style.zIndex=3),f.pixelHeight==null&&(f.pixelHeight=f.el.offsetHeight)),f.rowCount==null&&(f.rowCount=f.pixelHeight/a.layerConfig.lineHeight);var s=this.session.getFoldAt(f.row,0);if(f.$fold=s,s){var o=this.session.lineWidgets;f.row==s.end.row&&!o[s.start.row]?o[s.start.row]=f:f.hidden=!0}return this.session._emit("changeFold",{data:{start:{row:f.row}}}),this.$updateRows(),this.renderWidgets(null,a),this.onWidgetChanged(f),f},C.prototype.removeLineWidget=function(f){if(f._inDocument=!1,f.session=null,f.el&&f.el.parentNode&&f.el.parentNode.removeChild(f.el),f.editor&&f.editor.destroy)try{f.editor.destroy()}catch{}if(this.session.lineWidgets){var a=this.session.lineWidgets[f.row];if(a==f)this.session.lineWidgets[f.row]=f.$oldWidget,f.$oldWidget&&this.onWidgetChanged(f.$oldWidget);else for(;a;){if(a.$oldWidget==f){a.$oldWidget=f.$oldWidget;break}a=a.$oldWidget}}this.session._emit("changeFold",{data:{start:{row:f.row}}}),this.$updateRows()},C.prototype.getWidgetsAtRow=function(f){for(var a=this.session.lineWidgets,s=a&&a[f],o=[];s;)o.push(s),s=s.$oldWidget;return o},C.prototype.onWidgetChanged=function(f){this.session._changedWidgets.push(f),this.editor&&this.editor.renderer.updateFull()},C.prototype.measureWidgets=function(f,a){var s=this.session._changedWidgets,o=a.layerConfig;if(!(!s||!s.length)){for(var c=1/0,l=0;l0&&!o[c];)c--;this.firstRow=s.firstRow,this.lastRow=s.lastRow,a.$cursorLayer.config=s;for(var h=c;h<=l;h++){var d=o[h];if(!(!d||!d.el)){if(d.hidden){d.el.style.top=-100-(d.pixelHeight||0)+"px";continue}d._inDocument||(d._inDocument=!0,a.container.appendChild(d.el));var g=a.$cursorLayer.getPixelPosition({row:h,column:0},!0).top;d.coverLine||(g+=s.lineHeight*this.session.getRowLineCount(d.row)),d.el.style.top=g-s.offset+"px";var _=d.coverGutter?0:a.gutterWidth;d.fixedWidth||(_-=a.scrollLeft),d.el.style.left=_+"px",d.fullWidth&&d.screenWidth&&(d.el.style.minWidth=s.width+2*s.padding+"px"),d.fixedWidth?d.el.style.right=a.scrollBar.getWidth()+"px":d.el.style.right=""}}}},C}();p.LineWidgets=P}),ace.define("ace/keyboard/gutter_handler",["require","exports","module","ace/lib/keys","ace/mouse/default_gutter_handler"],function(r,p,m){var B=r("../lib/keys"),P=r("../mouse/default_gutter_handler").GutterTooltip,C=function(){function f(a){this.editor=a,this.gutterLayer=a.renderer.$gutterLayer,this.element=a.renderer.$gutter,this.lines=a.renderer.$gutterLayer.$lines,this.activeRowIndex=null,this.activeLane=null,this.annotationTooltip=new P(this.editor)}return f.prototype.addListener=function(){this.element.addEventListener("keydown",this.$onGutterKeyDown.bind(this)),this.element.addEventListener("focusout",this.$blurGutter.bind(this)),this.editor.on("mousewheel",this.$blurGutter.bind(this))},f.prototype.removeListener=function(){this.element.removeEventListener("keydown",this.$onGutterKeyDown.bind(this)),this.element.removeEventListener("focusout",this.$blurGutter.bind(this)),this.editor.off("mousewheel",this.$blurGutter.bind(this))},f.prototype.$onGutterKeyDown=function(a){if(this.annotationTooltip.isOpen){a.preventDefault(),a.keyCode===B.escape&&this.annotationTooltip.hide();return}if(a.target===this.element){if(a.keyCode!=B.enter)return;a.preventDefault();var s=this.editor.getCursorPosition().row;this.editor.isRowVisible(s)||this.editor.scrollToLine(s,!0,!0),setTimeout(function(){var d=this.$rowToRowIndex(this.gutterLayer.$cursorCell.row),g=this.$findNearestFoldWidget(d),_=this.$findNearestAnnotation(d);if(!(g===null&&_===null)){if(g===null&&_!==null){this.activeRowIndex=_,this.activeLane="annotation",this.$focusAnnotation(this.activeRowIndex);return}if(g!==null&&_===null){this.activeRowIndex=g,this.activeLane="fold",this.$focusFoldWidget(this.activeRowIndex);return}if(Math.abs(_-d)0||a+s=0&&this.$isFoldWidgetVisible(a-s))return a-s;if(a+s<=this.lines.getLength()-1&&this.$isFoldWidgetVisible(a+s))return a+s}return null},f.prototype.$findNearestAnnotation=function(a){if(this.$isAnnotationVisible(a))return a;for(var s=0;a-s>0||a+s=0&&this.$isAnnotationVisible(a-s))return a-s;if(a+s<=this.lines.getLength()-1&&this.$isAnnotationVisible(a+s))return a+s}return null},f.prototype.$focusFoldWidget=function(a){if(a!=null){var s=this.$getFoldWidget(a);s.classList.add(this.editor.renderer.keyboardFocusClassName),s.focus()}},f.prototype.$focusAnnotation=function(a){if(a!=null){var s=this.$getAnnotation(a);s.classList.add(this.editor.renderer.keyboardFocusClassName),s.setAttribute("role","button"),s.focus()}},f.prototype.$blurFoldWidget=function(a){var s=this.$getFoldWidget(a);s.classList.remove(this.editor.renderer.keyboardFocusClassName),s.blur()},f.prototype.$blurAnnotation=function(a){var s=this.$getAnnotation(a);s.classList.remove(this.editor.renderer.keyboardFocusClassName),s.removeAttribute("role"),s.blur()},f.prototype.$moveFoldWidgetUp=function(){for(var a=this.activeRowIndex;a>0;)if(a--,this.$isFoldWidgetVisible(a)){this.$blurFoldWidget(this.activeRowIndex),this.activeRowIndex=a,this.$focusFoldWidget(this.activeRowIndex);return}},f.prototype.$moveFoldWidgetDown=function(){for(var a=this.activeRowIndex;a0;)if(a--,this.$isAnnotationVisible(a)){this.$blurAnnotation(this.activeRowIndex),this.activeRowIndex=a,this.$focusAnnotation(this.activeRowIndex);return}},f.prototype.$moveAnnotationDown=function(){for(var a=this.activeRowIndex;a=A.length&&(A=void 0),{value:A&&A[O++],done:!A}}};throw new TypeError(T?"Object is not iterable.":"Symbol.iterator is not defined.")},P=r("./lib/oop"),C=r("./lib/dom"),f=r("./lib/lang"),a=r("./lib/useragent"),s=r("./keyboard/textinput").TextInput,o=r("./mouse/mouse_handler").MouseHandler,c=r("./mouse/fold_handler").FoldHandler,l=r("./keyboard/keybinding").KeyBinding,h=r("./edit_session").EditSession,d=r("./search").Search,g=r("./range").Range,_=r("./lib/event_emitter").EventEmitter,v=r("./commands/command_manager").CommandManager,k=r("./commands/default_commands").commands,I=r("./config"),S=r("./token_iterator").TokenIterator,b=r("./line_widgets").LineWidgets,x=r("./keyboard/gutter_handler").GutterKeyboardHandler,N=r("./config").nls,D=r("./clipboard"),R=r("./lib/keys"),w=function(){function A(T,L,O){this.$toDestroy=[];var H=T.getContainerElement();this.container=H,this.renderer=T,this.id="editor"+ ++A.$uid,this.commands=new v(a.isMac?"mac":"win",k),typeof document=="object"&&(this.textInput=new s(T.getTextAreaContainer(),this),this.renderer.textarea=this.textInput.getElement(),this.$mouseHandler=new o(this),new c(this)),this.keyBinding=new l(this),this.$search=new d().set({wrap:!0}),this.$historyTracker=this.$historyTracker.bind(this),this.commands.on("exec",this.$historyTracker),this.$initOperationListeners(),this._$emitInputEvent=f.delayedCall(function(){this._signal("input",{}),this.session&&!this.session.destroyed&&this.session.bgTokenizer.scheduleStart()}.bind(this)),this.on("change",function(V,W){W._$emitInputEvent.schedule(31)}),this.setSession(L||O&&O.session||new h("")),I.resetOptions(this),O&&this.setOptions(O),I._signal("editor",this)}return A.prototype.$initOperationListeners=function(){this.commands.on("exec",this.startOperation.bind(this),!0),this.commands.on("afterExec",this.endOperation.bind(this),!0),this.$opResetTimer=f.delayedCall(this.endOperation.bind(this,!0)),this.on("change",function(){this.curOp||(this.startOperation(),this.curOp.selectionBefore=this.$lastSel),this.curOp.docChanged=!0}.bind(this),!0),this.on("changeSelection",function(){this.curOp||(this.startOperation(),this.curOp.selectionBefore=this.$lastSel),this.curOp.selectionChanged=!0}.bind(this),!0)},A.prototype.startOperation=function(T){if(this.curOp){if(!T||this.curOp.command)return;this.prevOp=this.curOp}T||(this.previousCommand=null,T={}),this.$opResetTimer.schedule(),this.curOp=this.session.curOp={command:T.command||{},args:T.args,scrollTop:this.renderer.scrollTop},this.curOp.selectionBefore=this.selection.toJSON()},A.prototype.endOperation=function(T){if(this.curOp&&this.session){if(T&&T.returnValue===!1||!this.session)return this.curOp=null;if(T==!0&&this.curOp.command&&this.curOp.command.name=="mouse"||(this._signal("beforeEndOperation"),!this.curOp))return;var L=this.curOp.command,O=L&&L.scrollIntoView;if(O){switch(O){case"center-animate":O="animate";case"center":this.renderer.scrollCursorIntoView(null,.5);break;case"animate":case"cursor":this.renderer.scrollCursorIntoView();break;case"selectionPart":var H=this.selection.getRange(),V=this.renderer.layerConfig;(H.start.row>=V.lastRow||H.end.row<=V.firstRow)&&this.renderer.scrollSelectionIntoView(this.selection.anchor,this.selection.lead);break}O=="animate"&&this.renderer.animateScrolling(this.curOp.scrollTop)}var W=this.selection.toJSON();this.curOp.selectionAfter=W,this.$lastSel=this.selection.toJSON(),this.session.getUndoManager().addSelection(W),this.prevOp=this.curOp,this.curOp=null}},A.prototype.$historyTracker=function(T){if(this.$mergeUndoDeltas){var L=this.prevOp,O=this.$mergeableCommands,H=L.command&&T.command.name==L.command.name;if(T.command.name=="insertstring"){var V=T.args;this.mergeNextCommand===void 0&&(this.mergeNextCommand=!0),H=H&&this.mergeNextCommand&&(!/\s/.test(V)||/\s/.test(L.args)),this.mergeNextCommand=!0}else H=H&&O.indexOf(T.command.name)!==-1;this.$mergeUndoDeltas!="always"&&Date.now()-this.sequenceStartTime>2e3&&(H=!1),H?this.session.mergeUndoDeltas=!0:O.indexOf(T.command.name)!==-1&&(this.sequenceStartTime=Date.now())}},A.prototype.setKeyboardHandler=function(T,L){if(T&&typeof T=="string"&&T!="ace"){this.$keybindingId=T;var O=this;I.loadModule(["keybinding",T],function(H){O.$keybindingId==T&&O.keyBinding.setKeyboardHandler(H&&H.handler),L&&L()})}else this.$keybindingId=null,this.keyBinding.setKeyboardHandler(T),L&&L()},A.prototype.getKeyboardHandler=function(){return this.keyBinding.getKeyboardHandler()},A.prototype.setSession=function(T){if(this.session!=T){this.curOp&&this.endOperation(),this.curOp={};var L=this.session;if(L){this.session.off("change",this.$onDocumentChange),this.session.off("changeMode",this.$onChangeMode),this.session.off("tokenizerUpdate",this.$onTokenizerUpdate),this.session.off("changeTabSize",this.$onChangeTabSize),this.session.off("changeWrapLimit",this.$onChangeWrapLimit),this.session.off("changeWrapMode",this.$onChangeWrapMode),this.session.off("changeFold",this.$onChangeFold),this.session.off("changeFrontMarker",this.$onChangeFrontMarker),this.session.off("changeBackMarker",this.$onChangeBackMarker),this.session.off("changeBreakpoint",this.$onChangeBreakpoint),this.session.off("changeAnnotation",this.$onChangeAnnotation),this.session.off("changeOverwrite",this.$onCursorChange),this.session.off("changeScrollTop",this.$onScrollTopChange),this.session.off("changeScrollLeft",this.$onScrollLeftChange);var O=this.session.getSelection();O.off("changeCursor",this.$onCursorChange),O.off("changeSelection",this.$onSelectionChange)}this.session=T,T?(this.$onDocumentChange=this.onDocumentChange.bind(this),T.on("change",this.$onDocumentChange),this.renderer.setSession(T),this.$onChangeMode=this.onChangeMode.bind(this),T.on("changeMode",this.$onChangeMode),this.$onTokenizerUpdate=this.onTokenizerUpdate.bind(this),T.on("tokenizerUpdate",this.$onTokenizerUpdate),this.$onChangeTabSize=this.renderer.onChangeTabSize.bind(this.renderer),T.on("changeTabSize",this.$onChangeTabSize),this.$onChangeWrapLimit=this.onChangeWrapLimit.bind(this),T.on("changeWrapLimit",this.$onChangeWrapLimit),this.$onChangeWrapMode=this.onChangeWrapMode.bind(this),T.on("changeWrapMode",this.$onChangeWrapMode),this.$onChangeFold=this.onChangeFold.bind(this),T.on("changeFold",this.$onChangeFold),this.$onChangeFrontMarker=this.onChangeFrontMarker.bind(this),this.session.on("changeFrontMarker",this.$onChangeFrontMarker),this.$onChangeBackMarker=this.onChangeBackMarker.bind(this),this.session.on("changeBackMarker",this.$onChangeBackMarker),this.$onChangeBreakpoint=this.onChangeBreakpoint.bind(this),this.session.on("changeBreakpoint",this.$onChangeBreakpoint),this.$onChangeAnnotation=this.onChangeAnnotation.bind(this),this.session.on("changeAnnotation",this.$onChangeAnnotation),this.$onCursorChange=this.onCursorChange.bind(this),this.session.on("changeOverwrite",this.$onCursorChange),this.$onScrollTopChange=this.onScrollTopChange.bind(this),this.session.on("changeScrollTop",this.$onScrollTopChange),this.$onScrollLeftChange=this.onScrollLeftChange.bind(this),this.session.on("changeScrollLeft",this.$onScrollLeftChange),this.selection=T.getSelection(),this.selection.on("changeCursor",this.$onCursorChange),this.$onSelectionChange=this.onSelectionChange.bind(this),this.selection.on("changeSelection",this.$onSelectionChange),this.onChangeMode(),this.onCursorChange(),this.onScrollTopChange(),this.onScrollLeftChange(),this.onSelectionChange(),this.onChangeFrontMarker(),this.onChangeBackMarker(),this.onChangeBreakpoint(),this.onChangeAnnotation(),this.session.getUseWrapMode()&&this.renderer.adjustWrapLimit(),this.renderer.updateFull()):(this.selection=null,this.renderer.setSession(T)),this._signal("changeSession",{session:T,oldSession:L}),this.curOp=null,L&&L._signal("changeEditor",{oldEditor:this}),T&&T._signal("changeEditor",{editor:this}),T&&!T.destroyed&&T.bgTokenizer.scheduleStart()}},A.prototype.getSession=function(){return this.session},A.prototype.setValue=function(T,L){return this.session.doc.setValue(T),L?L==1?this.navigateFileEnd():L==-1&&this.navigateFileStart():this.selectAll(),T},A.prototype.getValue=function(){return this.session.getValue()},A.prototype.getSelection=function(){return this.selection},A.prototype.resize=function(T){this.renderer.onResize(T)},A.prototype.setTheme=function(T,L){this.renderer.setTheme(T,L)},A.prototype.getTheme=function(){return this.renderer.getTheme()},A.prototype.setStyle=function(T){this.renderer.setStyle(T)},A.prototype.unsetStyle=function(T){this.renderer.unsetStyle(T)},A.prototype.getFontSize=function(){return this.getOption("fontSize")||C.computedStyle(this.container).fontSize},A.prototype.setFontSize=function(T){this.setOption("fontSize",T)},A.prototype.$highlightBrackets=function(){if(!this.$highlightPending){var T=this;this.$highlightPending=!0,setTimeout(function(){T.$highlightPending=!1;var L=T.session;if(!(!L||L.destroyed)){L.$bracketHighlight&&(L.$bracketHighlight.markerIds.forEach(function(Y){L.removeMarker(Y)}),L.$bracketHighlight=null);var O=T.getCursorPosition(),H=T.getKeyboardHandler(),V=H&&H.$getDirectionForHighlight&&H.$getDirectionForHighlight(T),W=L.getMatchingBracketRanges(O,V);if(!W){var K=new S(L,O.row,O.column),Q=K.getCurrentToken();if(Q&&/\b(?:tag-open|tag-name)/.test(Q.type)){var ie=L.getMatchingTags(O);ie&&(W=[ie.openTagName,ie.closeTagName])}}if(!W&&L.$mode.getMatching&&(W=L.$mode.getMatching(T.session)),!W){T.getHighlightIndentGuides()&&T.renderer.$textLayer.$highlightIndentGuide();return}var J="ace_bracket";Array.isArray(W)?W.length==1&&(J="ace_error_bracket"):W=[W],W.length==2&&(g.comparePoints(W[0].end,W[1].start)==0?W=[g.fromPoints(W[0].start,W[1].end)]:g.comparePoints(W[0].start,W[1].end)==0&&(W=[g.fromPoints(W[1].start,W[0].end)])),L.$bracketHighlight={ranges:W,markerIds:W.map(function(Y){return L.addMarker(Y,J,"text")})},T.getHighlightIndentGuides()&&T.renderer.$textLayer.$highlightIndentGuide()}},50)}},A.prototype.focus=function(){this.textInput.focus()},A.prototype.isFocused=function(){return this.textInput.isFocused()},A.prototype.blur=function(){this.textInput.blur()},A.prototype.onFocus=function(T){this.$isFocused||(this.$isFocused=!0,this.renderer.showCursor(),this.renderer.visualizeFocus(),this._emit("focus",T))},A.prototype.onBlur=function(T){this.$isFocused&&(this.$isFocused=!1,this.renderer.hideCursor(),this.renderer.visualizeBlur(),this._emit("blur",T))},A.prototype.$cursorChange=function(){this.renderer.updateCursor(),this.$highlightBrackets(),this.$updateHighlightActiveLine()},A.prototype.onDocumentChange=function(T){var L=this.session.$useWrapMode,O=T.start.row==T.end.row?T.end.row:1/0;this.renderer.updateLines(T.start.row,O,L),this._signal("change",T),this.$cursorChange()},A.prototype.onTokenizerUpdate=function(T){var L=T.data;this.renderer.updateLines(L.first,L.last)},A.prototype.onScrollTopChange=function(){this.renderer.scrollToY(this.session.getScrollTop())},A.prototype.onScrollLeftChange=function(){this.renderer.scrollToX(this.session.getScrollLeft())},A.prototype.onCursorChange=function(){this.$cursorChange(),this._signal("changeSelection")},A.prototype.$updateHighlightActiveLine=function(){var T=this.getSession(),L;if(this.$highlightActiveLine&&((this.$selectionStyle!="line"||!this.selection.isMultiLine())&&(L=this.getCursorPosition()),this.renderer.theme&&this.renderer.theme.$selectionColorConflict&&!this.selection.isEmpty()&&(L=!1),this.renderer.$maxLines&&this.session.getLength()===1&&!(this.renderer.$minLines>1)&&(L=!1)),T.$highlightLineMarker&&!L)T.removeMarker(T.$highlightLineMarker.id),T.$highlightLineMarker=null;else if(!T.$highlightLineMarker&&L){var O=new g(L.row,L.column,L.row,1/0);O.id=T.addMarker(O,"ace_active-line","screenLine"),T.$highlightLineMarker=O}else L&&(T.$highlightLineMarker.start.row=L.row,T.$highlightLineMarker.end.row=L.row,T.$highlightLineMarker.start.column=L.column,T._signal("changeBackMarker"))},A.prototype.onSelectionChange=function(T){var L=this.session;if(L.$selectionMarker&&L.removeMarker(L.$selectionMarker),L.$selectionMarker=null,this.selection.isEmpty())this.$updateHighlightActiveLine();else{var O=this.selection.getRange(),H=this.getSelectionStyle();L.$selectionMarker=L.addMarker(O,"ace_selection",H)}var V=this.$highlightSelectedWord&&this.$getSelectionHighLightRegexp();this.session.highlight(V),this._signal("changeSelection")},A.prototype.$getSelectionHighLightRegexp=function(){var T=this.session,L=this.getSelectionRange();if(!(L.isEmpty()||L.isMultiLine())){var O=L.start.column,H=L.end.column,V=T.getLine(L.start.row),W=V.substring(O,H);if(!(W.length>5e3||!/[\w\d]/.test(W))){var K=this.$search.$assembleRegExp({wholeWord:!0,caseSensitive:!0,needle:W}),Q=V.substring(O-1,H+1);if(K.test(Q))return K}}},A.prototype.onChangeFrontMarker=function(){this.renderer.updateFrontMarkers()},A.prototype.onChangeBackMarker=function(){this.renderer.updateBackMarkers()},A.prototype.onChangeBreakpoint=function(){this.renderer.updateBreakpoints()},A.prototype.onChangeAnnotation=function(){this.renderer.setAnnotations(this.session.getAnnotations())},A.prototype.onChangeMode=function(T){this.renderer.updateText(),this._emit("changeMode",T)},A.prototype.onChangeWrapLimit=function(){this.renderer.updateFull()},A.prototype.onChangeWrapMode=function(){this.renderer.onResize(!0)},A.prototype.onChangeFold=function(){this.$updateHighlightActiveLine(),this.renderer.updateFull()},A.prototype.getSelectedText=function(){return this.session.getTextRange(this.getSelectionRange())},A.prototype.getCopyText=function(){var T=this.getSelectedText(),L=this.session.doc.getNewLineCharacter(),O=!1;if(!T&&this.$copyWithEmptySelection){O=!0;for(var H=this.selection.getAllRanges(),V=0;VY.search(/\S|$/)){var Q=Y.substr(V.column).search(/\S|$/);O.doc.removeInLine(V.row,V.column,V.column+Q)}}this.clearSelection();var ie=V.column,J=O.getState(V.row),Y=O.getLine(V.row),z=H.checkOutdent(J,Y,T);if(O.insert(V,T),W&&W.selection&&(W.selection.length==2?this.selection.setSelectionRange(new g(V.row,ie+W.selection[0],V.row,ie+W.selection[1])):this.selection.setSelectionRange(new g(V.row+W.selection[0],W.selection[1],V.row+W.selection[2],W.selection[3]))),this.$enableAutoIndent){if(O.getDocument().isNewLine(T)){var oe=H.getNextLineIndent(J,Y.slice(0,V.column),O.getTabString());O.insert({row:V.row+1,column:0},oe)}z&&H.autoOutdent(J,O,V.row)}},A.prototype.autoIndent=function(){var T=this.session,L=T.getMode(),O,H;if(this.selection.isEmpty())O=0,H=T.doc.getLength()-1;else{var V=this.getSelectionRange();O=V.start.row,H=V.end.row}for(var W="",K="",Q="",ie,J,Y,z=T.getTabString(),oe=O;oe<=H;oe++)oe>0&&(W=T.getState(oe-1),K=T.getLine(oe-1),Q=L.getNextLineIndent(W,K,z)),ie=T.getLine(oe),J=L.$getIndent(ie),Q!==J&&(J.length>0&&(Y=new g(oe,0,oe,J.length),T.remove(Y)),Q.length>0&&T.insert({row:oe,column:0},Q)),L.autoOutdent(W,T,oe)},A.prototype.onTextInput=function(T,L){if(!L)return this.keyBinding.onTextInput(T);this.startOperation({command:{name:"insertstring"}});var O=this.applyComposition.bind(this,T,L);this.selection.rangeCount?this.forEachSelection(O):O(),this.endOperation()},A.prototype.applyComposition=function(T,L){if(L.extendLeft||L.extendRight){var O=this.selection.getRange();O.start.column-=L.extendLeft,O.end.column+=L.extendRight,O.start.column<0&&(O.start.row--,O.start.column+=this.session.getLine(O.start.row).length+1),this.selection.setRange(O),!T&&!O.isEmpty()&&this.remove()}if((T||!this.selection.isEmpty())&&this.insert(T,!0),L.restoreStart||L.restoreEnd){var O=this.selection.getRange();O.start.column-=L.restoreStart,O.end.column-=L.restoreEnd,this.selection.setRange(O)}},A.prototype.onCommandKey=function(T,L,O){return this.keyBinding.onCommandKey(T,L,O)},A.prototype.setOverwrite=function(T){this.session.setOverwrite(T)},A.prototype.getOverwrite=function(){return this.session.getOverwrite()},A.prototype.toggleOverwrite=function(){this.session.toggleOverwrite()},A.prototype.setScrollSpeed=function(T){this.setOption("scrollSpeed",T)},A.prototype.getScrollSpeed=function(){return this.getOption("scrollSpeed")},A.prototype.setDragDelay=function(T){this.setOption("dragDelay",T)},A.prototype.getDragDelay=function(){return this.getOption("dragDelay")},A.prototype.setSelectionStyle=function(T){this.setOption("selectionStyle",T)},A.prototype.getSelectionStyle=function(){return this.getOption("selectionStyle")},A.prototype.setHighlightActiveLine=function(T){this.setOption("highlightActiveLine",T)},A.prototype.getHighlightActiveLine=function(){return this.getOption("highlightActiveLine")},A.prototype.setHighlightGutterLine=function(T){this.setOption("highlightGutterLine",T)},A.prototype.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},A.prototype.setHighlightSelectedWord=function(T){this.setOption("highlightSelectedWord",T)},A.prototype.getHighlightSelectedWord=function(){return this.$highlightSelectedWord},A.prototype.setAnimatedScroll=function(T){this.renderer.setAnimatedScroll(T)},A.prototype.getAnimatedScroll=function(){return this.renderer.getAnimatedScroll()},A.prototype.setShowInvisibles=function(T){this.renderer.setShowInvisibles(T)},A.prototype.getShowInvisibles=function(){return this.renderer.getShowInvisibles()},A.prototype.setDisplayIndentGuides=function(T){this.renderer.setDisplayIndentGuides(T)},A.prototype.getDisplayIndentGuides=function(){return this.renderer.getDisplayIndentGuides()},A.prototype.setHighlightIndentGuides=function(T){this.renderer.setHighlightIndentGuides(T)},A.prototype.getHighlightIndentGuides=function(){return this.renderer.getHighlightIndentGuides()},A.prototype.setShowPrintMargin=function(T){this.renderer.setShowPrintMargin(T)},A.prototype.getShowPrintMargin=function(){return this.renderer.getShowPrintMargin()},A.prototype.setPrintMarginColumn=function(T){this.renderer.setPrintMarginColumn(T)},A.prototype.getPrintMarginColumn=function(){return this.renderer.getPrintMarginColumn()},A.prototype.setReadOnly=function(T){this.setOption("readOnly",T)},A.prototype.getReadOnly=function(){return this.getOption("readOnly")},A.prototype.setBehavioursEnabled=function(T){this.setOption("behavioursEnabled",T)},A.prototype.getBehavioursEnabled=function(){return this.getOption("behavioursEnabled")},A.prototype.setWrapBehavioursEnabled=function(T){this.setOption("wrapBehavioursEnabled",T)},A.prototype.getWrapBehavioursEnabled=function(){return this.getOption("wrapBehavioursEnabled")},A.prototype.setShowFoldWidgets=function(T){this.setOption("showFoldWidgets",T)},A.prototype.getShowFoldWidgets=function(){return this.getOption("showFoldWidgets")},A.prototype.setFadeFoldWidgets=function(T){this.setOption("fadeFoldWidgets",T)},A.prototype.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},A.prototype.remove=function(T){this.selection.isEmpty()&&(T=="left"?this.selection.selectLeft():this.selection.selectRight());var L=this.getSelectionRange();if(this.getBehavioursEnabled()){var O=this.session,H=O.getState(L.start.row),V=O.getMode().transformAction(H,"deletion",this,O,L);if(L.end.column===0){var W=O.getTextRange(L);if(W[W.length-1]==` -`){var K=O.getLine(L.end.row);/^\s+$/.test(K)&&(L.end.column=K.length)}}V&&(L=V)}this.session.remove(L),this.clearSelection()},A.prototype.removeWordRight=function(){this.selection.isEmpty()&&this.selection.selectWordRight(),this.session.remove(this.getSelectionRange()),this.clearSelection()},A.prototype.removeWordLeft=function(){this.selection.isEmpty()&&this.selection.selectWordLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},A.prototype.removeToLineStart=function(){this.selection.isEmpty()&&this.selection.selectLineStart(),this.selection.isEmpty()&&this.selection.selectLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},A.prototype.removeToLineEnd=function(){this.selection.isEmpty()&&this.selection.selectLineEnd();var T=this.getSelectionRange();T.start.column==T.end.column&&T.start.row==T.end.row&&(T.end.column=0,T.end.row++),this.session.remove(T),this.clearSelection()},A.prototype.splitLine=function(){this.selection.isEmpty()||(this.session.remove(this.getSelectionRange()),this.clearSelection());var T=this.getCursorPosition();this.insert(` -`),this.moveCursorToPosition(T)},A.prototype.setGhostText=function(T,L){this.session.widgetManager||(this.session.widgetManager=new b(this.session),this.session.widgetManager.attach(this)),this.renderer.setGhostText(T,L)},A.prototype.removeGhostText=function(){this.session.widgetManager&&this.renderer.removeGhostText()},A.prototype.transposeLetters=function(){if(this.selection.isEmpty()){var T=this.getCursorPosition(),L=T.column;if(L!==0){var O=this.session.getLine(T.row),H,V;LQ.toLowerCase()?1:0});for(var V=new g(0,0,0,0),H=T.first;H<=T.last;H++){var W=L.getLine(H);V.start.row=H,V.end.row=H,V.end.column=W.length,L.replace(V,O[H-T.first])}},A.prototype.toggleCommentLines=function(){var T=this.session.getState(this.getCursorPosition().row),L=this.$getSelectedRows();this.session.getMode().toggleCommentLines(T,this.session,L.first,L.last)},A.prototype.toggleBlockComment=function(){var T=this.getCursorPosition(),L=this.session.getState(T.row),O=this.getSelectionRange();this.session.getMode().toggleBlockComment(L,this.session,O,T)},A.prototype.getNumberAt=function(T,L){var O=/[\-]?[0-9]+(?:\.[0-9]+)?/g;O.lastIndex=0;for(var H=this.session.getLine(T);O.lastIndex=L){var W={value:V[0],start:V.index,end:V.index+V[0].length};return W}}return null},A.prototype.modifyNumber=function(T){var L=this.selection.getCursor().row,O=this.selection.getCursor().column,H=new g(L,O-1,L,O),V=this.session.getTextRange(H);if(!isNaN(parseFloat(V))&&isFinite(V)){var W=this.getNumberAt(L,O);if(W){var K=W.value.indexOf(".")>=0?W.start+W.value.indexOf(".")+1:W.end,Q=W.start+W.value.length-K,ie=parseFloat(W.value);ie*=Math.pow(10,Q),K!==W.end&&O=K&&W<=Q&&(O=Re,ie.selection.clearSelection(),ie.moveCursorTo(T,K+H),ie.selection.selectTo(T,Q+H)),K=Q});for(var J=this.$toggleWordPairs,Y,z=0;z=Q&&K<=ie&&oe.match(/((?:https?|ftp):\/\/[\S]+)/)){J=oe.replace(/[\s:.,'";}\]]+$/,"");break}Q=ie}}catch(he){O={error:he}}finally{try{z&&!z.done&&(H=Y.return)&&H.call(Y)}finally{if(O)throw O.error}}return J},A.prototype.openLink=function(){var T=this.selection.getCursor(),L=this.findLinkAt(T.row,T.column);return L&&window.open(L,"_blank"),L!=null},A.prototype.removeLines=function(){var T=this.$getSelectedRows();this.session.removeFullLines(T.first,T.last),this.clearSelection()},A.prototype.duplicateSelection=function(){var T=this.selection,L=this.session,O=T.getRange(),H=T.isBackwards();if(O.isEmpty()){var V=O.start.row;L.duplicateLines(V,V)}else{var W=H?O.start:O.end,K=L.insert(W,L.getTextRange(O),!1);O.start=W,O.end=K,T.setSelectionRange(O,H)}},A.prototype.moveLinesDown=function(){this.$moveLines(1,!1)},A.prototype.moveLinesUp=function(){this.$moveLines(-1,!1)},A.prototype.moveText=function(T,L,O){return this.session.moveText(T,L,O)},A.prototype.copyLinesUp=function(){this.$moveLines(-1,!0)},A.prototype.copyLinesDown=function(){this.$moveLines(1,!0)},A.prototype.$moveLines=function(T,L){var O,H,V=this.selection;if(!V.inMultiSelectMode||this.inVirtualSelectionMode){var W=V.toOrientedRange();O=this.$getSelectedRows(W),H=this.session.$moveLines(O.first,O.last,L?0:T),L&&T==-1&&(H=0),W.moveBy(H,0),V.fromOrientedRange(W)}else{var K=V.rangeList.ranges;V.rangeList.detach(this.session),this.inVirtualSelectionMode=!0;for(var Q=0,ie=0,J=K.length,Y=0;Yhe+1)break;he=de.last}for(Y--,Q=this.session.$moveLines(oe,he,L?0:T),L&&T==-1&&(z=Y+1);z<=Y;)K[z].moveBy(Q,0),z++;L||(Q=0),ie+=Q}V.fromOrientedRange(V.ranges[0]),V.rangeList.attach(this.session),this.inVirtualSelectionMode=!1}},A.prototype.$getSelectedRows=function(T){return T=(T||this.getSelectionRange()).collapseRows(),{first:this.session.getRowFoldStart(T.start.row),last:this.session.getRowFoldEnd(T.end.row)}},A.prototype.onCompositionStart=function(T){this.renderer.showComposition(T)},A.prototype.onCompositionUpdate=function(T){this.renderer.setCompositionText(T)},A.prototype.onCompositionEnd=function(){this.renderer.hideComposition()},A.prototype.getFirstVisibleRow=function(){return this.renderer.getFirstVisibleRow()},A.prototype.getLastVisibleRow=function(){return this.renderer.getLastVisibleRow()},A.prototype.isRowVisible=function(T){return T>=this.getFirstVisibleRow()&&T<=this.getLastVisibleRow()},A.prototype.isRowFullyVisible=function(T){return T>=this.renderer.getFirstFullyVisibleRow()&&T<=this.renderer.getLastFullyVisibleRow()},A.prototype.$getVisibleRowCount=function(){return this.renderer.getScrollBottomRow()-this.renderer.getScrollTopRow()+1},A.prototype.$moveByPage=function(T,L){var O=this.renderer,H=this.renderer.layerConfig,V=T*Math.floor(H.height/H.lineHeight);L===!0?this.selection.$moveSelection(function(){this.moveCursorBy(V,0)}):L===!1&&(this.selection.moveCursorBy(V,0),this.selection.clearSelection());var W=O.scrollTop;O.scrollBy(0,V*H.lineHeight),L!=null&&O.scrollCursorIntoView(null,.5),O.animateScrolling(W)},A.prototype.selectPageDown=function(){this.$moveByPage(1,!0)},A.prototype.selectPageUp=function(){this.$moveByPage(-1,!0)},A.prototype.gotoPageDown=function(){this.$moveByPage(1,!1)},A.prototype.gotoPageUp=function(){this.$moveByPage(-1,!1)},A.prototype.scrollPageDown=function(){this.$moveByPage(1)},A.prototype.scrollPageUp=function(){this.$moveByPage(-1)},A.prototype.scrollToRow=function(T){this.renderer.scrollToRow(T)},A.prototype.scrollToLine=function(T,L,O,H){this.renderer.scrollToLine(T,L,O,H)},A.prototype.centerSelection=function(){var T=this.getSelectionRange(),L={row:Math.floor(T.start.row+(T.end.row-T.start.row)/2),column:Math.floor(T.start.column+(T.end.column-T.start.column)/2)};this.renderer.alignCursor(L,.5)},A.prototype.getCursorPosition=function(){return this.selection.getCursor()},A.prototype.getCursorPositionScreen=function(){return this.session.documentToScreenPosition(this.getCursorPosition())},A.prototype.getSelectionRange=function(){return this.selection.getRange()},A.prototype.selectAll=function(){this.selection.selectAll()},A.prototype.clearSelection=function(){this.selection.clearSelection()},A.prototype.moveCursorTo=function(T,L){this.selection.moveCursorTo(T,L)},A.prototype.moveCursorToPosition=function(T){this.selection.moveCursorToPosition(T)},A.prototype.jumpToMatching=function(T,L){var O=this.getCursorPosition(),H=new S(this.session,O.row,O.column),V=H.getCurrentToken(),W=0;V&&V.type.indexOf("tag-name")!==-1&&(V=H.stepBackward());var K=V||H.stepForward();if(K){var Q,ie=!1,J={},Y=O.column-K.start,z,oe={")":"(","(":"(","]":"[","[":"[","{":"{","}":"{"};do{if(K.value.match(/[{}()\[\]]/g)){for(;Y1?J[K.value]++:V.value==="=0;--W)this.$tryReplace(O[W],T)&&H++;return this.selection.setSelectionRange(V),H},A.prototype.$tryReplace=function(T,L){var O=this.session.getTextRange(T);return L=this.$search.replace(O,L),L!==null?(T.end=this.session.replace(T,L),T):null},A.prototype.getLastSearchOptions=function(){return this.$search.getOptions()},A.prototype.find=function(T,L,O){L||(L={}),typeof T=="string"||T instanceof RegExp?L.needle=T:typeof T=="object"&&P.mixin(L,T);var H=this.selection.getRange();L.needle==null&&(T=this.session.getTextRange(H)||this.$search.$options.needle,T||(H=this.session.getWordRange(H.start.row,H.start.column),T=this.session.getTextRange(H)),this.$search.set({needle:T})),this.$search.set(L),L.start||this.$search.set({start:H});var V=this.$search.find(this.session);if(L.preventScroll)return V;if(V)return this.revealRange(V,O),V;L.backwards?H.start=H.end:H.end=H.start,this.selection.setRange(H)},A.prototype.findNext=function(T,L){this.find({skipCurrent:!0,backwards:!1},T,L)},A.prototype.findPrevious=function(T,L){this.find(T,{skipCurrent:!0,backwards:!0},L)},A.prototype.revealRange=function(T,L){this.session.unfold(T),this.selection.setSelectionRange(T);var O=this.renderer.scrollTop;this.renderer.scrollSelectionIntoView(T.start,T.end,.5),L!==!1&&this.renderer.animateScrolling(O)},A.prototype.undo=function(){this.session.getUndoManager().undo(this.session),this.renderer.scrollCursorIntoView(null,.5)},A.prototype.redo=function(){this.session.getUndoManager().redo(this.session),this.renderer.scrollCursorIntoView(null,.5)},A.prototype.destroy=function(){this.$toDestroy&&(this.$toDestroy.forEach(function(T){T.destroy()}),this.$toDestroy=null),this.$mouseHandler&&this.$mouseHandler.destroy(),this.renderer.destroy(),this._signal("destroy",this),this.session&&this.session.destroy(),this._$emitInputEvent&&this._$emitInputEvent.cancel(),this.removeAllListeners()},A.prototype.setAutoScrollEditorIntoView=function(T){if(T){var L,O=this,H=!1;this.$scrollAnchor||(this.$scrollAnchor=document.createElement("div"));var V=this.$scrollAnchor;V.style.cssText="position:absolute",this.container.insertBefore(V,this.container.firstChild);var W=this.on("changeSelection",function(){H=!0}),K=this.renderer.on("beforeRender",function(){H&&(L=O.renderer.container.getBoundingClientRect())}),Q=this.renderer.on("afterRender",function(){if(H&&L&&(O.isFocused()||O.searchBox&&O.searchBox.isFocused())){var ie=O.renderer,J=ie.$cursorLayer.$pixelPos,Y=ie.layerConfig,z=J.top-Y.offset;J.top>=0&&z+L.top<0?H=!0:J.topwindow.innerHeight?H=!1:H=null,H!=null&&(V.style.top=z+"px",V.style.left=J.left+"px",V.style.height=Y.lineHeight+"px",V.scrollIntoView(H)),H=L=null}});this.setAutoScrollEditorIntoView=function(ie){ie||(delete this.setAutoScrollEditorIntoView,this.off("changeSelection",W),this.renderer.off("afterRender",Q),this.renderer.off("beforeRender",K))}}},A.prototype.$resetCursorStyle=function(){var T=this.$cursorStyle||"ace",L=this.renderer.$cursorLayer;L&&(L.setSmoothBlinking(/smooth/.test(T)),L.isBlinking=!this.$readOnly&&T!="wide",C.setCssClass(L.element,"ace_slim-cursors",/slim/.test(T)))},A.prototype.prompt=function(T,L,O){var H=this;I.loadModule("ace/ext/prompt",function(V){V.prompt(H,T,L,O)})},A}();w.$uid=0,w.prototype.curOp=null,w.prototype.prevOp={},w.prototype.$mergeableCommands=["backspace","del","insertstring"],w.prototype.$toggleWordPairs=[["first","last"],["true","false"],["yes","no"],["width","height"],["top","bottom"],["right","left"],["on","off"],["x","y"],["get","set"],["max","min"],["horizontal","vertical"],["show","hide"],["add","remove"],["up","down"],["before","after"],["even","odd"],["in","out"],["inside","outside"],["next","previous"],["increase","decrease"],["attach","detach"],["&&","||"],["==","!="]],P.implement(w.prototype,_),I.defineOptions(w.prototype,"editor",{selectionStyle:{set:function(A){this.onSelectionChange(),this._signal("changeSelectionStyle",{data:A})},initialValue:"line"},highlightActiveLine:{set:function(){this.$updateHighlightActiveLine()},initialValue:!0},highlightSelectedWord:{set:function(A){this.$onSelectionChange()},initialValue:!0},readOnly:{set:function(A){this.textInput.setReadOnly(A),this.$resetCursorStyle()},initialValue:!1},copyWithEmptySelection:{set:function(A){this.textInput.setCopyWithEmptySelection(A)},initialValue:!1},cursorStyle:{set:function(A){this.$resetCursorStyle()},values:["ace","slim","smooth","wide"],initialValue:"ace"},mergeUndoDeltas:{values:[!1,!0,"always"],initialValue:!0},behavioursEnabled:{initialValue:!0},wrapBehavioursEnabled:{initialValue:!0},enableAutoIndent:{initialValue:!0},autoScrollEditorIntoView:{set:function(A){this.setAutoScrollEditorIntoView(A)}},keyboardHandler:{set:function(A){this.setKeyboardHandler(A)},get:function(){return this.$keybindingId},handlesSet:!0},value:{set:function(A){this.session.setValue(A)},get:function(){return this.getValue()},handlesSet:!0,hidden:!0},session:{set:function(A){this.setSession(A)},get:function(){return this.session},handlesSet:!0,hidden:!0},showLineNumbers:{set:function(A){this.renderer.$gutterLayer.setShowLineNumbers(A),this.renderer.$loop.schedule(this.renderer.CHANGE_GUTTER),A&&this.$relativeLineNumbers?F.attach(this):F.detach(this)},initialValue:!0},relativeLineNumbers:{set:function(A){this.$showLineNumbers&&A?F.attach(this):F.detach(this)}},placeholder:{set:function(A){this.$updatePlaceholder||(this.$updatePlaceholder=function(){var T=this.session&&(this.renderer.$composition||this.session.getLength()>1||this.session.getLine(0).length>0);if(T&&this.renderer.placeholderNode)this.renderer.off("afterRender",this.$updatePlaceholder),C.removeCssClass(this.container,"ace_hasPlaceholder"),this.renderer.placeholderNode.remove(),this.renderer.placeholderNode=null;else if(!T&&!this.renderer.placeholderNode){this.renderer.on("afterRender",this.$updatePlaceholder),C.addCssClass(this.container,"ace_hasPlaceholder");var L=C.createElement("div");L.className="ace_placeholder",L.textContent=this.$placeholder||"",this.renderer.placeholderNode=L,this.renderer.content.appendChild(this.renderer.placeholderNode)}else!T&&this.renderer.placeholderNode&&(this.renderer.placeholderNode.textContent=this.$placeholder||"")}.bind(this),this.on("input",this.$updatePlaceholder)),this.$updatePlaceholder()}},enableKeyboardAccessibility:{set:function(A){var T={name:"blurTextInput",description:"Set focus to the editor content div to allow tabbing through the page",bindKey:"Esc",exec:function(H){H.blur(),H.renderer.scroller.focus()},readOnly:!0},L=function(H){if(H.target==this.renderer.scroller&&H.keyCode===R.enter){H.preventDefault();var V=this.getCursorPosition().row;this.isRowVisible(V)||this.scrollToLine(V,!0,!0),this.focus()}},O;A?(this.renderer.enableKeyboardAccessibility=!0,this.renderer.keyboardFocusClassName="ace_keyboard-focus",this.textInput.getElement().setAttribute("tabindex",-1),this.renderer.scroller.setAttribute("tabindex",0),this.renderer.scroller.setAttribute("role","group"),this.renderer.scroller.setAttribute("aria-roledescription",N("editor")),this.renderer.scroller.classList.add(this.renderer.keyboardFocusClassName),this.renderer.scroller.setAttribute("aria-label",N("Editor content, press Enter to start editing, press Escape to exit")),this.renderer.scroller.addEventListener("keyup",L.bind(this)),this.commands.addCommand(T),this.renderer.$gutter.setAttribute("tabindex",0),this.renderer.$gutter.setAttribute("aria-hidden",!1),this.renderer.$gutter.setAttribute("role","group"),this.renderer.$gutter.setAttribute("aria-roledescription",N("editor")),this.renderer.$gutter.setAttribute("aria-label",N("Editor gutter, press Enter to interact with controls using arrow keys, press Escape to exit")),this.renderer.$gutter.classList.add(this.renderer.keyboardFocusClassName),this.renderer.content.setAttribute("aria-hidden",!0),O||(O=new x(this)),O.addListener()):(this.renderer.enableKeyboardAccessibility=!1,this.textInput.getElement().setAttribute("tabindex",0),this.renderer.scroller.setAttribute("tabindex",-1),this.renderer.scroller.removeAttribute("role"),this.renderer.scroller.removeAttribute("aria-roledescription"),this.renderer.scroller.classList.remove(this.renderer.keyboardFocusClassName),this.renderer.scroller.removeAttribute("aria-label"),this.renderer.scroller.removeEventListener("keyup",L.bind(this)),this.commands.removeCommand(T),this.renderer.content.removeAttribute("aria-hidden"),this.renderer.$gutter.setAttribute("tabindex",-1),this.renderer.$gutter.setAttribute("aria-hidden",!0),this.renderer.$gutter.removeAttribute("role"),this.renderer.$gutter.removeAttribute("aria-roledescription"),this.renderer.$gutter.removeAttribute("aria-label"),this.renderer.$gutter.classList.remove(this.renderer.keyboardFocusClassName),O&&O.removeListener())},initialValue:!1},customScrollbar:"renderer",hScrollBarAlwaysVisible:"renderer",vScrollBarAlwaysVisible:"renderer",highlightGutterLine:"renderer",animatedScroll:"renderer",showInvisibles:"renderer",showPrintMargin:"renderer",printMarginColumn:"renderer",printMargin:"renderer",fadeFoldWidgets:"renderer",showFoldWidgets:"renderer",displayIndentGuides:"renderer",highlightIndentGuides:"renderer",showGutter:"renderer",fontSize:"renderer",fontFamily:"renderer",maxLines:"renderer",minLines:"renderer",scrollPastEnd:"renderer",fixedWidthGutter:"renderer",theme:"renderer",hasCssTransforms:"renderer",maxPixelHeight:"renderer",useTextareaForIME:"renderer",useResizeObserver:"renderer",useSvgGutterIcons:"renderer",showFoldedAnnotations:"renderer",scrollSpeed:"$mouseHandler",dragDelay:"$mouseHandler",dragEnabled:"$mouseHandler",focusTimeout:"$mouseHandler",tooltipFollowsMouse:"$mouseHandler",firstLineNumber:"session",overwrite:"session",newLineMode:"session",useWorker:"session",useSoftTabs:"session",navigateWithinSoftTabs:"session",tabSize:"session",wrap:"session",indentedSoftWrap:"session",foldStyle:"session",mode:"session"});var F={getText:function(A,T){return(Math.abs(A.selection.lead.row-T)||T+1+(T<9?"·":""))+""},getWidth:function(A,T,L){return Math.max(T.toString().length,(L.lastRow+1).toString().length,2)*L.characterWidth},update:function(A,T){T.renderer.$loop.schedule(T.renderer.CHANGE_GUTTER)},attach:function(A){A.renderer.$gutterLayer.$renderer=this,A.on("changeSelection",this.update),this.update(null,A)},detach:function(A){A.renderer.$gutterLayer.$renderer==this&&(A.renderer.$gutterLayer.$renderer=null),A.off("changeSelection",this.update),this.update(null,A)}};p.Editor=w}),ace.define("ace/undomanager",["require","exports","module","ace/range"],function(r,p,m){var B=function(){function S(){this.$maxRev=0,this.$fromUndo=!1,this.$undoDepth=1/0,this.reset()}return S.prototype.addSession=function(b){this.$session=b},S.prototype.add=function(b,x,N){if(!this.$fromUndo&&b!=this.$lastDelta){if(this.$keepRedoStack||(this.$redoStack.length=0),x===!1||!this.lastDeltas){this.lastDeltas=[];var D=this.$undoStack.length;D>this.$undoDepth-1&&this.$undoStack.splice(0,D-this.$undoDepth+1),this.$undoStack.push(this.lastDeltas),b.id=this.$rev=++this.$maxRev}(b.action=="remove"||b.action=="insert")&&(this.$lastDelta=b),this.lastDeltas.push(b)}},S.prototype.addSelection=function(b,x){this.selections.push({value:b,rev:x||this.$rev})},S.prototype.startNewGroup=function(){return this.lastDeltas=null,this.$rev},S.prototype.markIgnored=function(b,x){x==null&&(x=this.$rev+1);for(var N=this.$undoStack,D=N.length;D--;){var R=N[D][0];if(R.id<=b)break;R.id0},S.prototype.canRedo=function(){return this.$redoStack.length>0},S.prototype.bookmark=function(b){b==null&&(b=this.$rev),this.mark=b},S.prototype.isAtBookmark=function(){return this.$rev===this.mark},S.prototype.toJSON=function(){},S.prototype.fromJSON=function(){},S.prototype.$prettyPrint=function(b){return b?o(b):o(this.$undoStack)+` +`),h=[],d=0;d=v;N--)if(w(N,Number.MAX_VALUE,x))return;if(c.wrap!=!1){for(N=M,v=_.row;N>=v;N--)if(w(N,Number.MAX_VALUE,x))return}}};else var y=function(N){var D=_.row;if(!w(D,_.column,N)){for(D=D+1;D<=M;D++)if(w(D,0,N))return;if(c.wrap!=!1){for(D=v,M=_.row;D<=M;D++)if(w(D,0,N))return}}};if(c.$isMultiLine)var I=l.length,w=function(x,N,D){var R=h?x-I+1:x;if(!(R<0||R+I>o.getLength())){var S=o.getLine(R),F=S.search(l[0]);if(!(!h&&FN)&&D(R,F,R+I-1,E))return!0}}};else if(h)var w=function(N,D,R){var S=o.getLine(N),F=[],A,E=0;for(l.lastIndex=0;A=l.exec(S);){var O=A[0].length;if(E=A.index,!O){if(E>=S.length)break;l.lastIndex=E+=1}if(A.index+O>D)break;F.push(A.index,O)}for(var k=F.length-1;k>=0;k-=2){var H=F[k-1],O=F[k];if(R(N,H,N,H+O))return!0}};else var w=function(N,D,R){var S=o.getLine(N),F,A;for(l.lastIndex=D;A=l.exec(S);){var E=A[0].length;if(F=A.index,R(N,F,N,F+E))return!0;if(!E&&(l.lastIndex=F+=1,F>=S.length))return!1}};return{forEach:y}},r}();function a(r,o){function c(l){return/\w/.test(l)||o.regExp?"\\b":""}return c(r[0])+r+c(r[r.length-1])}p.Search=f}),ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"],function(s,p,m){var B=s("../lib/keys"),P=s("../lib/useragent"),C=B.KEY_MODS;function f(r,o){this.platform=o||(P.isMac?"mac":"win"),this.commands={},this.commandKeyBinding={},this.addCommands(r),this.$singleCommand=!0}function a(r,o){f.call(this,r,o),this.$singleCommand=!1}a.prototype=f.prototype,function(){this.addCommand=function(o){this.commands[o.name]&&this.removeCommand(o),this.commands[o.name]=o,o.bindKey&&this._buildKeyHash(o)},this.removeCommand=function(o,c){var l=o&&(typeof o=="string"?o:o.name);o=this.commands[l],c||delete this.commands[l];var h=this.commandKeyBinding;for(var d in h){var g=h[d];if(g==o)delete h[d];else if(Array.isArray(g)){var _=g.indexOf(o);_!=-1&&(g.splice(_,1),g.length==1&&(h[d]=g[0]))}}},this.bindKey=function(o,c,l){if(typeof o=="object"&&o&&(l==null&&(l=o.position),o=o[this.platform]),!!o){if(typeof c=="function")return this.addCommand({exec:c,bindKey:o,name:c.name||o});o.split("|").forEach(function(h){var d="";if(h.indexOf(" ")!=-1){var g=h.split(/\s+/);h=g.pop(),g.forEach(function(M){var y=this.parseKeys(M),I=C[y.hashId]+y.key;d+=(d?" ":"")+I,this._addCommandToBinding(d,"chainKeys")},this),d+=" "}var _=this.parseKeys(h),v=C[_.hashId]+_.key;this._addCommandToBinding(d+v,c,l)},this)}};function r(o){return typeof o=="object"&&o.bindKey&&o.bindKey.position||(o.isDefault?-100:0)}this._addCommandToBinding=function(o,c,l){var h=this.commandKeyBinding,d;if(!c)delete h[o];else if(!h[o]||this.$singleCommand)h[o]=c;else{Array.isArray(h[o])?(d=h[o].indexOf(c))!=-1&&h[o].splice(d,1):h[o]=[h[o]],typeof l!="number"&&(l=r(c));var g=h[o];for(d=0;dl)break}g.splice(d,0,c)}},this.addCommands=function(o){o&&Object.keys(o).forEach(function(c){var l=o[c];if(l){if(typeof l=="string")return this.bindKey(l,c);typeof l=="function"&&(l={exec:l}),typeof l=="object"&&(l.name||(l.name=c),this.addCommand(l))}},this)},this.removeCommands=function(o){Object.keys(o).forEach(function(c){this.removeCommand(o[c])},this)},this.bindKeys=function(o){Object.keys(o).forEach(function(c){this.bindKey(c,o[c])},this)},this._buildKeyHash=function(o){this.bindKey(o.bindKey,o)},this.parseKeys=function(o){var c=o.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(v){return v}),l=c.pop(),h=B[l];if(B.FUNCTION_KEYS[h])l=B.FUNCTION_KEYS[h].toLowerCase();else if(c.length){if(c.length==1&&c[0]=="shift")return{key:l.toUpperCase(),hashId:-1}}else return{key:l,hashId:-1};for(var d=0,g=c.length;g--;){var _=B.KEY_MODS[c[g]];if(_==null)return typeof console<"u"&&console.error("invalid modifier "+c[g]+" in "+o),!1;d|=_}return{key:l,hashId:d}},this.findKeyCommand=function(c,l){var h=C[c]+l;return this.commandKeyBinding[h]},this.handleKeyboard=function(o,c,l,h){if(!(h<0)){var d=C[c]+l,g=this.commandKeyBinding[d];return o.$keyChain&&(o.$keyChain+=" "+d,g=this.commandKeyBinding[o.$keyChain]||g),g&&(g=="chainKeys"||g[g.length-1]=="chainKeys")?(o.$keyChain=o.$keyChain||d,{command:"null"}):(o.$keyChain&&((!c||c==4)&&l.length==1?o.$keyChain=o.$keyChain.slice(0,-d.length-1):(c==-1||h>0)&&(o.$keyChain="")),{command:g})}},this.getStatusText=function(o,c){return c.$keyChain||""}}.call(f.prototype),p.HashHandler=f,p.MultiHashHandler=a}),ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"],function(s,p,m){var B=this&&this.__extends||function(){var r=function(o,c){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,h){l.__proto__=h}||function(l,h){for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&(l[d]=h[d])},r(o,c)};return function(o,c){if(typeof c!="function"&&c!==null)throw new TypeError("Class extends value "+String(c)+" is not a constructor or null");r(o,c);function l(){this.constructor=o}o.prototype=c===null?Object.create(c):(l.prototype=c.prototype,new l)}}(),P=s("../lib/oop"),C=s("../keyboard/hash_handler").MultiHashHandler,f=s("../lib/event_emitter").EventEmitter,a=function(r){B(o,r);function o(c,l){var h=r.call(this,l,c)||this;return h.byName=h.commands,h.setDefaultHandler("exec",function(d){return d.args?d.command.exec(d.editor,d.args,d.event,!1):d.command.exec(d.editor,{},d.event,!0)}),h}return o.prototype.exec=function(c,l,h){if(Array.isArray(c)){for(var d=c.length;d--;)if(this.exec(c[d],l,h))return!0;return!1}if(typeof c=="string"&&(c=this.commands[c]),!c||l&&l.$readOnly&&!c.readOnly||this.$checkCommandState!=!1&&c.isAvailable&&!c.isAvailable(l))return!1;var g={editor:l,command:c,args:h};return g.returnValue=this._emit("exec",g),this._signal("afterExec",g),g.returnValue!==!1},o.prototype.toggleRecording=function(c){if(!this.$inReplay)return c&&c._emit("changeStatus"),this.recording?(this.macro.pop(),this.off("exec",this.$addCommandToMacro),this.macro.length||(this.macro=this.oldMacro),this.recording=!1):(this.$addCommandToMacro||(this.$addCommandToMacro=function(l){this.macro.push([l.command,l.args])}.bind(this)),this.oldMacro=this.macro,this.macro=[],this.on("exec",this.$addCommandToMacro),this.recording=!0)},o.prototype.replay=function(c){if(!(this.$inReplay||!this.macro)){if(this.recording)return this.toggleRecording(c);try{this.$inReplay=!0,this.macro.forEach(function(l){typeof l=="string"?this.exec(l,c):this.exec(l[0],c,l[1])},this)}finally{this.$inReplay=!1}}},o.prototype.trimMacro=function(c){return c.map(function(l){return typeof l[0]!="string"&&(l[0]=l[0].name),l[1]||(l=l[0]),l})},o}(C);P.implement(a.prototype,f),p.CommandManager=a}),ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"],function(s,p,m){var B=s("../lib/lang"),P=s("../config"),C=s("../range").Range;function f(r,o){return{win:r,mac:o}}p.commands=[{name:"showSettingsMenu",description:"Show settings menu",bindKey:f("Ctrl-,","Command-,"),exec:function(r){P.loadModule("ace/ext/settings_menu",function(o){o.init(r),r.showSettingsMenu()})},readOnly:!0},{name:"goToNextError",description:"Go to next error",bindKey:f("Alt-E","F4"),exec:function(r){P.loadModule("ace/ext/error_marker",function(o){o.showErrorMarker(r,1)})},scrollIntoView:"animate",readOnly:!0},{name:"goToPreviousError",description:"Go to previous error",bindKey:f("Alt-Shift-E","Shift-F4"),exec:function(r){P.loadModule("ace/ext/error_marker",function(o){o.showErrorMarker(r,-1)})},scrollIntoView:"animate",readOnly:!0},{name:"selectall",description:"Select all",bindKey:f("Ctrl-A","Command-A"),exec:function(r){r.selectAll()},readOnly:!0},{name:"centerselection",description:"Center selection",bindKey:f(null,"Ctrl-L"),exec:function(r){r.centerSelection()},readOnly:!0},{name:"gotoline",description:"Go to line...",bindKey:f("Ctrl-L","Command-L"),exec:function(r,o){typeof o=="number"&&!isNaN(o)&&r.gotoLine(o),r.prompt({$type:"gotoLine"})},readOnly:!0},{name:"fold",bindKey:f("Alt-L|Ctrl-F1","Command-Alt-L|Command-F1"),exec:function(r){r.session.toggleFold(!1)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"unfold",bindKey:f("Alt-Shift-L|Ctrl-Shift-F1","Command-Alt-Shift-L|Command-Shift-F1"),exec:function(r){r.session.toggleFold(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleFoldWidget",description:"Toggle fold widget",bindKey:f("F2","F2"),exec:function(r){r.session.toggleFoldWidget()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"toggleParentFoldWidget",description:"Toggle parent fold widget",bindKey:f("Alt-F2","Alt-F2"),exec:function(r){r.session.toggleFoldWidget(!0)},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"foldall",description:"Fold all",bindKey:f(null,"Ctrl-Command-Option-0"),exec:function(r){r.session.foldAll()},scrollIntoView:"center",readOnly:!0},{name:"foldAllComments",description:"Fold all comments",bindKey:f(null,"Ctrl-Command-Option-0"),exec:function(r){r.session.foldAllComments()},scrollIntoView:"center",readOnly:!0},{name:"foldOther",description:"Fold other",bindKey:f("Alt-0","Command-Option-0"),exec:function(r){r.session.foldAll(),r.session.unfold(r.selection.getAllRanges())},scrollIntoView:"center",readOnly:!0},{name:"unfoldall",description:"Unfold all",bindKey:f("Alt-Shift-0","Command-Option-Shift-0"),exec:function(r){r.session.unfold()},scrollIntoView:"center",readOnly:!0},{name:"findnext",description:"Find next",bindKey:f("Ctrl-K","Command-G"),exec:function(r){r.findNext()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"findprevious",description:"Find previous",bindKey:f("Ctrl-Shift-K","Command-Shift-G"),exec:function(r){r.findPrevious()},multiSelectAction:"forEach",scrollIntoView:"center",readOnly:!0},{name:"selectOrFindNext",description:"Select or find next",bindKey:f("Alt-K","Ctrl-G"),exec:function(r){r.selection.isEmpty()?r.selection.selectWord():r.findNext()},readOnly:!0},{name:"selectOrFindPrevious",description:"Select or find previous",bindKey:f("Alt-Shift-K","Ctrl-Shift-G"),exec:function(r){r.selection.isEmpty()?r.selection.selectWord():r.findPrevious()},readOnly:!0},{name:"find",description:"Find",bindKey:f("Ctrl-F","Command-F"),exec:function(r){P.loadModule("ace/ext/searchbox",function(o){o.Search(r)})},readOnly:!0},{name:"overwrite",description:"Overwrite",bindKey:"Insert",exec:function(r){r.toggleOverwrite()},readOnly:!0},{name:"selecttostart",description:"Select to start",bindKey:f("Ctrl-Shift-Home","Command-Shift-Home|Command-Shift-Up"),exec:function(r){r.getSelection().selectFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotostart",description:"Go to start",bindKey:f("Ctrl-Home","Command-Home|Command-Up"),exec:function(r){r.navigateFileStart()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectup",description:"Select up",bindKey:f("Shift-Up","Shift-Up|Ctrl-Shift-P"),exec:function(r){r.getSelection().selectUp()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golineup",description:"Go line up",bindKey:f("Up","Up|Ctrl-P"),exec:function(r,o){r.navigateUp(o.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttoend",description:"Select to end",bindKey:f("Ctrl-Shift-End","Command-Shift-End|Command-Shift-Down"),exec:function(r){r.getSelection().selectFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"gotoend",description:"Go to end",bindKey:f("Ctrl-End","Command-End|Command-Down"),exec:function(r){r.navigateFileEnd()},multiSelectAction:"forEach",readOnly:!0,scrollIntoView:"animate",aceCommandGroup:"fileJump"},{name:"selectdown",description:"Select down",bindKey:f("Shift-Down","Shift-Down|Ctrl-Shift-N"),exec:function(r){r.getSelection().selectDown()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"golinedown",description:"Go line down",bindKey:f("Down","Down|Ctrl-N"),exec:function(r,o){r.navigateDown(o.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordleft",description:"Select word left",bindKey:f("Ctrl-Shift-Left","Option-Shift-Left"),exec:function(r){r.getSelection().selectWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordleft",description:"Go to word left",bindKey:f("Ctrl-Left","Option-Left"),exec:function(r){r.navigateWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolinestart",description:"Select to line start",bindKey:f("Alt-Shift-Left","Command-Shift-Left|Ctrl-Shift-A"),exec:function(r){r.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolinestart",description:"Go to line start",bindKey:f("Alt-Left|Home","Command-Left|Home|Ctrl-A"),exec:function(r){r.navigateLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectleft",description:"Select left",bindKey:f("Shift-Left","Shift-Left|Ctrl-Shift-B"),exec:function(r){r.getSelection().selectLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoleft",description:"Go to left",bindKey:f("Left","Left|Ctrl-B"),exec:function(r,o){r.navigateLeft(o.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectwordright",description:"Select word right",bindKey:f("Ctrl-Shift-Right","Option-Shift-Right"),exec:function(r){r.getSelection().selectWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotowordright",description:"Go to word right",bindKey:f("Ctrl-Right","Option-Right"),exec:function(r){r.navigateWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selecttolineend",description:"Select to line end",bindKey:f("Alt-Shift-Right","Command-Shift-Right|Shift-End|Ctrl-Shift-E"),exec:function(r){r.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotolineend",description:"Go to line end",bindKey:f("Alt-Right|End","Command-Right|End|Ctrl-E"),exec:function(r){r.navigateLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectright",description:"Select right",bindKey:f("Shift-Right","Shift-Right"),exec:function(r){r.getSelection().selectRight()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"gotoright",description:"Go to right",bindKey:f("Right","Right|Ctrl-F"),exec:function(r,o){r.navigateRight(o.times)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectpagedown",description:"Select page down",bindKey:"Shift-PageDown",exec:function(r){r.selectPageDown()},readOnly:!0},{name:"pagedown",description:"Page down",bindKey:f(null,"Option-PageDown"),exec:function(r){r.scrollPageDown()},readOnly:!0},{name:"gotopagedown",description:"Go to page down",bindKey:f("PageDown","PageDown|Ctrl-V"),exec:function(r){r.gotoPageDown()},readOnly:!0},{name:"selectpageup",description:"Select page up",bindKey:"Shift-PageUp",exec:function(r){r.selectPageUp()},readOnly:!0},{name:"pageup",description:"Page up",bindKey:f(null,"Option-PageUp"),exec:function(r){r.scrollPageUp()},readOnly:!0},{name:"gotopageup",description:"Go to page up",bindKey:"PageUp",exec:function(r){r.gotoPageUp()},readOnly:!0},{name:"scrollup",description:"Scroll up",bindKey:f("Ctrl-Up",null),exec:function(r){r.renderer.scrollBy(0,-2*r.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"scrolldown",description:"Scroll down",bindKey:f("Ctrl-Down",null),exec:function(r){r.renderer.scrollBy(0,2*r.renderer.layerConfig.lineHeight)},readOnly:!0},{name:"selectlinestart",description:"Select line start",bindKey:"Shift-Home",exec:function(r){r.getSelection().selectLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"selectlineend",description:"Select line end",bindKey:"Shift-End",exec:function(r){r.getSelection().selectLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"togglerecording",description:"Toggle recording",bindKey:f("Ctrl-Alt-E","Command-Option-E"),exec:function(r){r.commands.toggleRecording(r)},readOnly:!0},{name:"replaymacro",description:"Replay macro",bindKey:f("Ctrl-Shift-E","Command-Shift-E"),exec:function(r){r.commands.replay(r)},readOnly:!0},{name:"jumptomatching",description:"Jump to matching",bindKey:f("Ctrl-\\|Ctrl-P","Command-\\"),exec:function(r){r.jumpToMatching()},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"selecttomatching",description:"Select to matching",bindKey:f("Ctrl-Shift-\\|Ctrl-Shift-P","Command-Shift-\\"),exec:function(r){r.jumpToMatching(!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"expandToMatching",description:"Expand to matching",bindKey:f("Ctrl-Shift-M","Ctrl-Shift-M"),exec:function(r){r.jumpToMatching(!0,!0)},multiSelectAction:"forEach",scrollIntoView:"animate",readOnly:!0},{name:"passKeysToBrowser",description:"Pass keys to browser",bindKey:f(null,null),exec:function(){},passEvent:!0,readOnly:!0},{name:"copy",description:"Copy",exec:function(r){},readOnly:!0},{name:"cut",description:"Cut",exec:function(r){var o=r.$copyWithEmptySelection&&r.selection.isEmpty(),c=o?r.selection.getLineRange():r.selection.getRange();r._emit("cut",c),c.isEmpty()||r.session.remove(c),r.clearSelection()},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"paste",description:"Paste",exec:function(r,o){r.$handlePaste(o)},scrollIntoView:"cursor"},{name:"removeline",description:"Remove line",bindKey:f("Ctrl-D","Command-D"),exec:function(r){r.removeLines()},scrollIntoView:"cursor",multiSelectAction:"forEachLine"},{name:"duplicateSelection",description:"Duplicate selection",bindKey:f("Ctrl-Shift-D","Command-Shift-D"),exec:function(r){r.duplicateSelection()},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"sortlines",description:"Sort lines",bindKey:f("Ctrl-Alt-S","Command-Alt-S"),exec:function(r){r.sortLines()},scrollIntoView:"selection",multiSelectAction:"forEachLine"},{name:"togglecomment",description:"Toggle comment",bindKey:f("Ctrl-/","Command-/"),exec:function(r){r.toggleCommentLines()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"toggleBlockComment",description:"Toggle block comment",bindKey:f("Ctrl-Shift-/","Command-Shift-/"),exec:function(r){r.toggleBlockComment()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"modifyNumberUp",description:"Modify number up",bindKey:f("Ctrl-Shift-Up","Alt-Shift-Up"),exec:function(r){r.modifyNumber(1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"modifyNumberDown",description:"Modify number down",bindKey:f("Ctrl-Shift-Down","Alt-Shift-Down"),exec:function(r){r.modifyNumber(-1)},scrollIntoView:"cursor",multiSelectAction:"forEach"},{name:"replace",description:"Replace",bindKey:f("Ctrl-H","Command-Option-F"),exec:function(r){P.loadModule("ace/ext/searchbox",function(o){o.Search(r,!0)})}},{name:"undo",description:"Undo",bindKey:f("Ctrl-Z","Command-Z"),exec:function(r){r.undo()}},{name:"redo",description:"Redo",bindKey:f("Ctrl-Shift-Z|Ctrl-Y","Command-Shift-Z|Command-Y"),exec:function(r){r.redo()}},{name:"copylinesup",description:"Copy lines up",bindKey:f("Alt-Shift-Up","Command-Option-Up"),exec:function(r){r.copyLinesUp()},scrollIntoView:"cursor"},{name:"movelinesup",description:"Move lines up",bindKey:f("Alt-Up","Option-Up"),exec:function(r){r.moveLinesUp()},scrollIntoView:"cursor"},{name:"copylinesdown",description:"Copy lines down",bindKey:f("Alt-Shift-Down","Command-Option-Down"),exec:function(r){r.copyLinesDown()},scrollIntoView:"cursor"},{name:"movelinesdown",description:"Move lines down",bindKey:f("Alt-Down","Option-Down"),exec:function(r){r.moveLinesDown()},scrollIntoView:"cursor"},{name:"del",description:"Delete",bindKey:f("Delete","Delete|Ctrl-D|Shift-Delete"),exec:function(r){r.remove("right")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"backspace",description:"Backspace",bindKey:f("Shift-Backspace|Backspace","Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"),exec:function(r){r.remove("left")},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"cut_or_delete",description:"Cut or delete",bindKey:f("Shift-Delete",null),exec:function(r){if(r.selection.isEmpty())r.remove("left");else return!1},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolinestart",description:"Remove to line start",bindKey:f("Alt-Backspace","Command-Backspace"),exec:function(r){r.removeToLineStart()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolineend",description:"Remove to line end",bindKey:f("Alt-Delete","Ctrl-K|Command-Delete"),exec:function(r){r.removeToLineEnd()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolinestarthard",description:"Remove to line start hard",bindKey:f("Ctrl-Shift-Backspace",null),exec:function(r){var o=r.selection.getRange();o.start.column=0,r.session.remove(o)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removetolineendhard",description:"Remove to line end hard",bindKey:f("Ctrl-Shift-Delete",null),exec:function(r){var o=r.selection.getRange();o.end.column=Number.MAX_VALUE,r.session.remove(o)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordleft",description:"Remove word left",bindKey:f("Ctrl-Backspace","Alt-Backspace|Ctrl-Alt-Backspace"),exec:function(r){r.removeWordLeft()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"removewordright",description:"Remove word right",bindKey:f("Ctrl-Delete","Alt-Delete"),exec:function(r){r.removeWordRight()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"outdent",description:"Outdent",bindKey:f("Shift-Tab","Shift-Tab"),exec:function(r){r.blockOutdent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"indent",description:"Indent",bindKey:f("Tab","Tab"),exec:function(r){r.indent()},multiSelectAction:"forEach",scrollIntoView:"selectionPart"},{name:"blockoutdent",description:"Block outdent",bindKey:f("Ctrl-[","Ctrl-["),exec:function(r){r.blockOutdent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"blockindent",description:"Block indent",bindKey:f("Ctrl-]","Ctrl-]"),exec:function(r){r.blockIndent()},multiSelectAction:"forEachLine",scrollIntoView:"selectionPart"},{name:"insertstring",description:"Insert string",exec:function(r,o){r.insert(o)},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"inserttext",description:"Insert text",exec:function(r,o){r.insert(B.stringRepeat(o.text||"",o.times||1))},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"splitline",description:"Split line",bindKey:f(null,"Ctrl-O"),exec:function(r){r.splitLine()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"transposeletters",description:"Transpose letters",bindKey:f("Alt-Shift-X","Ctrl-T"),exec:function(r){r.transposeLetters()},multiSelectAction:function(r){r.transposeSelections(1)},scrollIntoView:"cursor"},{name:"touppercase",description:"To uppercase",bindKey:f("Ctrl-U","Ctrl-U"),exec:function(r){r.toUpperCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"tolowercase",description:"To lowercase",bindKey:f("Ctrl-Shift-U","Ctrl-Shift-U"),exec:function(r){r.toLowerCase()},multiSelectAction:"forEach",scrollIntoView:"cursor"},{name:"autoindent",description:"Auto Indent",bindKey:f(null,null),exec:function(r){r.autoIndent()},multiSelectAction:"forEachLine",scrollIntoView:"animate"},{name:"expandtoline",description:"Expand to line",bindKey:f("Ctrl-Shift-L","Command-Shift-L"),exec:function(r){var o=r.selection.getRange();o.start.column=o.end.column=0,o.end.row++,r.selection.setRange(o,!1)},multiSelectAction:"forEach",scrollIntoView:"cursor",readOnly:!0},{name:"openlink",bindKey:f("Ctrl+F3","F3"),exec:function(r){r.openLink()}},{name:"joinlines",description:"Join lines",bindKey:f(null,null),exec:function(r){for(var o=r.selection.isBackwards(),c=o?r.selection.getSelectionLead():r.selection.getSelectionAnchor(),l=o?r.selection.getSelectionAnchor():r.selection.getSelectionLead(),h=r.session.doc.getLine(c.row).length,d=r.session.doc.getTextRange(r.selection.getRange()),g=d.replace(/\n\s*/," ").length,_=r.session.doc.getLine(c.row),v=c.row+1;v<=l.row+1;v++){var M=B.stringTrimLeft(B.stringTrimRight(r.session.doc.getLine(v)));M.length!==0&&(M=" "+M),_+=M}l.row+10?(r.selection.moveCursorTo(c.row,c.column),r.selection.selectTo(c.row,c.column+g)):(h=r.session.doc.getLine(c.row).length>h?h+1:h,r.selection.moveCursorTo(c.row,h))},multiSelectAction:"forEach",readOnly:!0},{name:"invertSelection",description:"Invert selection",bindKey:f(null,null),exec:function(r){var o=r.session.doc.getLength()-1,c=r.session.doc.getLine(o).length,l=r.selection.rangeList.ranges,h=[];l.length<1&&(l=[r.selection.getRange()]);for(var d=0;da[r].column&&r++,l.unshift(r,0),a.splice.apply(a,l),this.$updateRows()}}},C.prototype.$updateRows=function(){var f=this.session.lineWidgets;if(f){var a=!0;f.forEach(function(r,o){if(r)for(a=!1,r.row=o;r.$oldWidget;)r.$oldWidget.row=o,r=r.$oldWidget}),a&&(this.session.lineWidgets=null)}},C.prototype.$registerLineWidget=function(f){this.session.lineWidgets||(this.session.lineWidgets=new Array(this.session.getLength()));var a=this.session.lineWidgets[f.row];return a&&(f.$oldWidget=a,a.el&&a.el.parentNode&&(a.el.parentNode.removeChild(a.el),a._inDocument=!1)),this.session.lineWidgets[f.row]=f,f},C.prototype.addLineWidget=function(f){if(this.$registerLineWidget(f),f.session=this.session,!this.editor)return f;var a=this.editor.renderer;f.html&&!f.el&&(f.el=B.createElement("div"),f.el.innerHTML=f.html),f.text&&!f.el&&(f.el=B.createElement("div"),f.el.textContent=f.text),f.el&&(B.addCssClass(f.el,"ace_lineWidgetContainer"),f.className&&B.addCssClass(f.el,f.className),f.el.style.position="absolute",f.el.style.zIndex=5,a.container.appendChild(f.el),f._inDocument=!0,f.coverGutter||(f.el.style.zIndex=3),f.pixelHeight==null&&(f.pixelHeight=f.el.offsetHeight)),f.rowCount==null&&(f.rowCount=f.pixelHeight/a.layerConfig.lineHeight);var r=this.session.getFoldAt(f.row,0);if(f.$fold=r,r){var o=this.session.lineWidgets;f.row==r.end.row&&!o[r.start.row]?o[r.start.row]=f:f.hidden=!0}return this.session._emit("changeFold",{data:{start:{row:f.row}}}),this.$updateRows(),this.renderWidgets(null,a),this.onWidgetChanged(f),f},C.prototype.removeLineWidget=function(f){if(f._inDocument=!1,f.session=null,f.el&&f.el.parentNode&&f.el.parentNode.removeChild(f.el),f.editor&&f.editor.destroy)try{f.editor.destroy()}catch{}if(this.session.lineWidgets){var a=this.session.lineWidgets[f.row];if(a==f)this.session.lineWidgets[f.row]=f.$oldWidget,f.$oldWidget&&this.onWidgetChanged(f.$oldWidget);else for(;a;){if(a.$oldWidget==f){a.$oldWidget=f.$oldWidget;break}a=a.$oldWidget}}this.session._emit("changeFold",{data:{start:{row:f.row}}}),this.$updateRows()},C.prototype.getWidgetsAtRow=function(f){for(var a=this.session.lineWidgets,r=a&&a[f],o=[];r;)o.push(r),r=r.$oldWidget;return o},C.prototype.onWidgetChanged=function(f){this.session._changedWidgets.push(f),this.editor&&this.editor.renderer.updateFull()},C.prototype.measureWidgets=function(f,a){var r=this.session._changedWidgets,o=a.layerConfig;if(!(!r||!r.length)){for(var c=1/0,l=0;l0&&!o[c];)c--;this.firstRow=r.firstRow,this.lastRow=r.lastRow,a.$cursorLayer.config=r;for(var h=c;h<=l;h++){var d=o[h];if(!(!d||!d.el)){if(d.hidden){d.el.style.top=-100-(d.pixelHeight||0)+"px";continue}d._inDocument||(d._inDocument=!0,a.container.appendChild(d.el));var g=a.$cursorLayer.getPixelPosition({row:h,column:0},!0).top;d.coverLine||(g+=r.lineHeight*this.session.getRowLineCount(d.row)),d.el.style.top=g-r.offset+"px";var _=d.coverGutter?0:a.gutterWidth;d.fixedWidth||(_-=a.scrollLeft),d.el.style.left=_+"px",d.fullWidth&&d.screenWidth&&(d.el.style.minWidth=r.width+2*r.padding+"px"),d.fixedWidth?d.el.style.right=a.scrollBar.getWidth()+"px":d.el.style.right=""}}}},C}();p.LineWidgets=P}),ace.define("ace/keyboard/gutter_handler",["require","exports","module","ace/lib/keys","ace/mouse/default_gutter_handler"],function(s,p,m){var B=s("../lib/keys"),P=s("../mouse/default_gutter_handler").GutterTooltip,C=function(){function f(a){this.editor=a,this.gutterLayer=a.renderer.$gutterLayer,this.element=a.renderer.$gutter,this.lines=a.renderer.$gutterLayer.$lines,this.activeRowIndex=null,this.activeLane=null,this.annotationTooltip=new P(this.editor)}return f.prototype.addListener=function(){this.element.addEventListener("keydown",this.$onGutterKeyDown.bind(this)),this.element.addEventListener("focusout",this.$blurGutter.bind(this)),this.editor.on("mousewheel",this.$blurGutter.bind(this))},f.prototype.removeListener=function(){this.element.removeEventListener("keydown",this.$onGutterKeyDown.bind(this)),this.element.removeEventListener("focusout",this.$blurGutter.bind(this)),this.editor.off("mousewheel",this.$blurGutter.bind(this))},f.prototype.$onGutterKeyDown=function(a){if(this.annotationTooltip.isOpen){a.preventDefault(),a.keyCode===B.escape&&this.annotationTooltip.hide();return}if(a.target===this.element){if(a.keyCode!=B.enter)return;a.preventDefault();var r=this.editor.getCursorPosition().row;this.editor.isRowVisible(r)||this.editor.scrollToLine(r,!0,!0),setTimeout(function(){var d=this.$rowToRowIndex(this.gutterLayer.$cursorCell.row),g=this.$findNearestFoldWidget(d),_=this.$findNearestAnnotation(d);if(!(g===null&&_===null)){if(g===null&&_!==null){this.activeRowIndex=_,this.activeLane="annotation",this.$focusAnnotation(this.activeRowIndex);return}if(g!==null&&_===null){this.activeRowIndex=g,this.activeLane="fold",this.$focusFoldWidget(this.activeRowIndex);return}if(Math.abs(_-d)0||a+r=0&&this.$isFoldWidgetVisible(a-r))return a-r;if(a+r<=this.lines.getLength()-1&&this.$isFoldWidgetVisible(a+r))return a+r}return null},f.prototype.$findNearestAnnotation=function(a){if(this.$isAnnotationVisible(a))return a;for(var r=0;a-r>0||a+r=0&&this.$isAnnotationVisible(a-r))return a-r;if(a+r<=this.lines.getLength()-1&&this.$isAnnotationVisible(a+r))return a+r}return null},f.prototype.$focusFoldWidget=function(a){if(a!=null){var r=this.$getFoldWidget(a);r.classList.add(this.editor.renderer.keyboardFocusClassName),r.focus()}},f.prototype.$focusAnnotation=function(a){if(a!=null){var r=this.$getAnnotation(a);r.classList.add(this.editor.renderer.keyboardFocusClassName),r.setAttribute("role","button"),r.focus()}},f.prototype.$blurFoldWidget=function(a){var r=this.$getFoldWidget(a);r.classList.remove(this.editor.renderer.keyboardFocusClassName),r.blur()},f.prototype.$blurAnnotation=function(a){var r=this.$getAnnotation(a);r.classList.remove(this.editor.renderer.keyboardFocusClassName),r.removeAttribute("role"),r.blur()},f.prototype.$moveFoldWidgetUp=function(){for(var a=this.activeRowIndex;a>0;)if(a--,this.$isFoldWidgetVisible(a)){this.$blurFoldWidget(this.activeRowIndex),this.activeRowIndex=a,this.$focusFoldWidget(this.activeRowIndex);return}},f.prototype.$moveFoldWidgetDown=function(){for(var a=this.activeRowIndex;a0;)if(a--,this.$isAnnotationVisible(a)){this.$blurAnnotation(this.activeRowIndex),this.activeRowIndex=a,this.$focusAnnotation(this.activeRowIndex);return}},f.prototype.$moveAnnotationDown=function(){for(var a=this.activeRowIndex;a=A.length&&(A=void 0),{value:A&&A[k++],done:!A}}};throw new TypeError(E?"Object is not iterable.":"Symbol.iterator is not defined.")},P=s("./lib/oop"),C=s("./lib/dom"),f=s("./lib/lang"),a=s("./lib/useragent"),r=s("./keyboard/textinput").TextInput,o=s("./mouse/mouse_handler").MouseHandler,c=s("./mouse/fold_handler").FoldHandler,l=s("./keyboard/keybinding").KeyBinding,h=s("./edit_session").EditSession,d=s("./search").Search,g=s("./range").Range,_=s("./lib/event_emitter").EventEmitter,v=s("./commands/command_manager").CommandManager,M=s("./commands/default_commands").commands,y=s("./config"),I=s("./token_iterator").TokenIterator,w=s("./line_widgets").LineWidgets,x=s("./keyboard/gutter_handler").GutterKeyboardHandler,N=s("./config").nls,D=s("./clipboard"),R=s("./lib/keys"),S=function(){function A(E,O,k){this.$toDestroy=[];var H=E.getContainerElement();this.container=H,this.renderer=E,this.id="editor"+ ++A.$uid,this.commands=new v(a.isMac?"mac":"win",M),typeof document=="object"&&(this.textInput=new r(E.getTextAreaContainer(),this),this.renderer.textarea=this.textInput.getElement(),this.$mouseHandler=new o(this),new c(this)),this.keyBinding=new l(this),this.$search=new d().set({wrap:!0}),this.$historyTracker=this.$historyTracker.bind(this),this.commands.on("exec",this.$historyTracker),this.$initOperationListeners(),this._$emitInputEvent=f.delayedCall(function(){this._signal("input",{}),this.session&&!this.session.destroyed&&this.session.bgTokenizer.scheduleStart()}.bind(this)),this.on("change",function(V,W){W._$emitInputEvent.schedule(31)}),this.setSession(O||k&&k.session||new h("")),y.resetOptions(this),k&&this.setOptions(k),y._signal("editor",this)}return A.prototype.$initOperationListeners=function(){this.commands.on("exec",this.startOperation.bind(this),!0),this.commands.on("afterExec",this.endOperation.bind(this),!0),this.$opResetTimer=f.delayedCall(this.endOperation.bind(this,!0)),this.on("change",function(){this.curOp||(this.startOperation(),this.curOp.selectionBefore=this.$lastSel),this.curOp.docChanged=!0}.bind(this),!0),this.on("changeSelection",function(){this.curOp||(this.startOperation(),this.curOp.selectionBefore=this.$lastSel),this.curOp.selectionChanged=!0}.bind(this),!0)},A.prototype.startOperation=function(E){if(this.curOp){if(!E||this.curOp.command)return;this.prevOp=this.curOp}E||(this.previousCommand=null,E={}),this.$opResetTimer.schedule(),this.curOp=this.session.curOp={command:E.command||{},args:E.args,scrollTop:this.renderer.scrollTop},this.curOp.selectionBefore=this.selection.toJSON()},A.prototype.endOperation=function(E){if(this.curOp&&this.session){if(E&&E.returnValue===!1||!this.session)return this.curOp=null;if(E==!0&&this.curOp.command&&this.curOp.command.name=="mouse"||(this._signal("beforeEndOperation"),!this.curOp))return;var O=this.curOp.command,k=O&&O.scrollIntoView;if(k){switch(k){case"center-animate":k="animate";case"center":this.renderer.scrollCursorIntoView(null,.5);break;case"animate":case"cursor":this.renderer.scrollCursorIntoView();break;case"selectionPart":var H=this.selection.getRange(),V=this.renderer.layerConfig;(H.start.row>=V.lastRow||H.end.row<=V.firstRow)&&this.renderer.scrollSelectionIntoView(this.selection.anchor,this.selection.lead);break}k=="animate"&&this.renderer.animateScrolling(this.curOp.scrollTop)}var W=this.selection.toJSON();this.curOp.selectionAfter=W,this.$lastSel=this.selection.toJSON(),this.session.getUndoManager().addSelection(W),this.prevOp=this.curOp,this.curOp=null}},A.prototype.$historyTracker=function(E){if(this.$mergeUndoDeltas){var O=this.prevOp,k=this.$mergeableCommands,H=O.command&&E.command.name==O.command.name;if(E.command.name=="insertstring"){var V=E.args;this.mergeNextCommand===void 0&&(this.mergeNextCommand=!0),H=H&&this.mergeNextCommand&&(!/\s/.test(V)||/\s/.test(O.args)),this.mergeNextCommand=!0}else H=H&&k.indexOf(E.command.name)!==-1;this.$mergeUndoDeltas!="always"&&Date.now()-this.sequenceStartTime>2e3&&(H=!1),H?this.session.mergeUndoDeltas=!0:k.indexOf(E.command.name)!==-1&&(this.sequenceStartTime=Date.now())}},A.prototype.setKeyboardHandler=function(E,O){if(E&&typeof E=="string"&&E!="ace"){this.$keybindingId=E;var k=this;y.loadModule(["keybinding",E],function(H){k.$keybindingId==E&&k.keyBinding.setKeyboardHandler(H&&H.handler),O&&O()})}else this.$keybindingId=null,this.keyBinding.setKeyboardHandler(E),O&&O()},A.prototype.getKeyboardHandler=function(){return this.keyBinding.getKeyboardHandler()},A.prototype.setSession=function(E){if(this.session!=E){this.curOp&&this.endOperation(),this.curOp={};var O=this.session;if(O){this.session.off("change",this.$onDocumentChange),this.session.off("changeMode",this.$onChangeMode),this.session.off("tokenizerUpdate",this.$onTokenizerUpdate),this.session.off("changeTabSize",this.$onChangeTabSize),this.session.off("changeWrapLimit",this.$onChangeWrapLimit),this.session.off("changeWrapMode",this.$onChangeWrapMode),this.session.off("changeFold",this.$onChangeFold),this.session.off("changeFrontMarker",this.$onChangeFrontMarker),this.session.off("changeBackMarker",this.$onChangeBackMarker),this.session.off("changeBreakpoint",this.$onChangeBreakpoint),this.session.off("changeAnnotation",this.$onChangeAnnotation),this.session.off("changeOverwrite",this.$onCursorChange),this.session.off("changeScrollTop",this.$onScrollTopChange),this.session.off("changeScrollLeft",this.$onScrollLeftChange);var k=this.session.getSelection();k.off("changeCursor",this.$onCursorChange),k.off("changeSelection",this.$onSelectionChange)}this.session=E,E?(this.$onDocumentChange=this.onDocumentChange.bind(this),E.on("change",this.$onDocumentChange),this.renderer.setSession(E),this.$onChangeMode=this.onChangeMode.bind(this),E.on("changeMode",this.$onChangeMode),this.$onTokenizerUpdate=this.onTokenizerUpdate.bind(this),E.on("tokenizerUpdate",this.$onTokenizerUpdate),this.$onChangeTabSize=this.renderer.onChangeTabSize.bind(this.renderer),E.on("changeTabSize",this.$onChangeTabSize),this.$onChangeWrapLimit=this.onChangeWrapLimit.bind(this),E.on("changeWrapLimit",this.$onChangeWrapLimit),this.$onChangeWrapMode=this.onChangeWrapMode.bind(this),E.on("changeWrapMode",this.$onChangeWrapMode),this.$onChangeFold=this.onChangeFold.bind(this),E.on("changeFold",this.$onChangeFold),this.$onChangeFrontMarker=this.onChangeFrontMarker.bind(this),this.session.on("changeFrontMarker",this.$onChangeFrontMarker),this.$onChangeBackMarker=this.onChangeBackMarker.bind(this),this.session.on("changeBackMarker",this.$onChangeBackMarker),this.$onChangeBreakpoint=this.onChangeBreakpoint.bind(this),this.session.on("changeBreakpoint",this.$onChangeBreakpoint),this.$onChangeAnnotation=this.onChangeAnnotation.bind(this),this.session.on("changeAnnotation",this.$onChangeAnnotation),this.$onCursorChange=this.onCursorChange.bind(this),this.session.on("changeOverwrite",this.$onCursorChange),this.$onScrollTopChange=this.onScrollTopChange.bind(this),this.session.on("changeScrollTop",this.$onScrollTopChange),this.$onScrollLeftChange=this.onScrollLeftChange.bind(this),this.session.on("changeScrollLeft",this.$onScrollLeftChange),this.selection=E.getSelection(),this.selection.on("changeCursor",this.$onCursorChange),this.$onSelectionChange=this.onSelectionChange.bind(this),this.selection.on("changeSelection",this.$onSelectionChange),this.onChangeMode(),this.onCursorChange(),this.onScrollTopChange(),this.onScrollLeftChange(),this.onSelectionChange(),this.onChangeFrontMarker(),this.onChangeBackMarker(),this.onChangeBreakpoint(),this.onChangeAnnotation(),this.session.getUseWrapMode()&&this.renderer.adjustWrapLimit(),this.renderer.updateFull()):(this.selection=null,this.renderer.setSession(E)),this._signal("changeSession",{session:E,oldSession:O}),this.curOp=null,O&&O._signal("changeEditor",{oldEditor:this}),E&&E._signal("changeEditor",{editor:this}),E&&!E.destroyed&&E.bgTokenizer.scheduleStart()}},A.prototype.getSession=function(){return this.session},A.prototype.setValue=function(E,O){return this.session.doc.setValue(E),O?O==1?this.navigateFileEnd():O==-1&&this.navigateFileStart():this.selectAll(),E},A.prototype.getValue=function(){return this.session.getValue()},A.prototype.getSelection=function(){return this.selection},A.prototype.resize=function(E){this.renderer.onResize(E)},A.prototype.setTheme=function(E,O){this.renderer.setTheme(E,O)},A.prototype.getTheme=function(){return this.renderer.getTheme()},A.prototype.setStyle=function(E){this.renderer.setStyle(E)},A.prototype.unsetStyle=function(E){this.renderer.unsetStyle(E)},A.prototype.getFontSize=function(){return this.getOption("fontSize")||C.computedStyle(this.container).fontSize},A.prototype.setFontSize=function(E){this.setOption("fontSize",E)},A.prototype.$highlightBrackets=function(){if(!this.$highlightPending){var E=this;this.$highlightPending=!0,setTimeout(function(){E.$highlightPending=!1;var O=E.session;if(!(!O||O.destroyed)){O.$bracketHighlight&&(O.$bracketHighlight.markerIds.forEach(function(Y){O.removeMarker(Y)}),O.$bracketHighlight=null);var k=E.getCursorPosition(),H=E.getKeyboardHandler(),V=H&&H.$getDirectionForHighlight&&H.$getDirectionForHighlight(E),W=O.getMatchingBracketRanges(k,V);if(!W){var K=new I(O,k.row,k.column),Q=K.getCurrentToken();if(Q&&/\b(?:tag-open|tag-name)/.test(Q.type)){var ie=O.getMatchingTags(k);ie&&(W=[ie.openTagName,ie.closeTagName])}}if(!W&&O.$mode.getMatching&&(W=O.$mode.getMatching(E.session)),!W){E.getHighlightIndentGuides()&&E.renderer.$textLayer.$highlightIndentGuide();return}var J="ace_bracket";Array.isArray(W)?W.length==1&&(J="ace_error_bracket"):W=[W],W.length==2&&(g.comparePoints(W[0].end,W[1].start)==0?W=[g.fromPoints(W[0].start,W[1].end)]:g.comparePoints(W[0].start,W[1].end)==0&&(W=[g.fromPoints(W[1].start,W[0].end)])),O.$bracketHighlight={ranges:W,markerIds:W.map(function(Y){return O.addMarker(Y,J,"text")})},E.getHighlightIndentGuides()&&E.renderer.$textLayer.$highlightIndentGuide()}},50)}},A.prototype.focus=function(){this.textInput.focus()},A.prototype.isFocused=function(){return this.textInput.isFocused()},A.prototype.blur=function(){this.textInput.blur()},A.prototype.onFocus=function(E){this.$isFocused||(this.$isFocused=!0,this.renderer.showCursor(),this.renderer.visualizeFocus(),this._emit("focus",E))},A.prototype.onBlur=function(E){this.$isFocused&&(this.$isFocused=!1,this.renderer.hideCursor(),this.renderer.visualizeBlur(),this._emit("blur",E))},A.prototype.$cursorChange=function(){this.renderer.updateCursor(),this.$highlightBrackets(),this.$updateHighlightActiveLine()},A.prototype.onDocumentChange=function(E){var O=this.session.$useWrapMode,k=E.start.row==E.end.row?E.end.row:1/0;this.renderer.updateLines(E.start.row,k,O),this._signal("change",E),this.$cursorChange()},A.prototype.onTokenizerUpdate=function(E){var O=E.data;this.renderer.updateLines(O.first,O.last)},A.prototype.onScrollTopChange=function(){this.renderer.scrollToY(this.session.getScrollTop())},A.prototype.onScrollLeftChange=function(){this.renderer.scrollToX(this.session.getScrollLeft())},A.prototype.onCursorChange=function(){this.$cursorChange(),this._signal("changeSelection")},A.prototype.$updateHighlightActiveLine=function(){var E=this.getSession(),O;if(this.$highlightActiveLine&&((this.$selectionStyle!="line"||!this.selection.isMultiLine())&&(O=this.getCursorPosition()),this.renderer.theme&&this.renderer.theme.$selectionColorConflict&&!this.selection.isEmpty()&&(O=!1),this.renderer.$maxLines&&this.session.getLength()===1&&!(this.renderer.$minLines>1)&&(O=!1)),E.$highlightLineMarker&&!O)E.removeMarker(E.$highlightLineMarker.id),E.$highlightLineMarker=null;else if(!E.$highlightLineMarker&&O){var k=new g(O.row,O.column,O.row,1/0);k.id=E.addMarker(k,"ace_active-line","screenLine"),E.$highlightLineMarker=k}else O&&(E.$highlightLineMarker.start.row=O.row,E.$highlightLineMarker.end.row=O.row,E.$highlightLineMarker.start.column=O.column,E._signal("changeBackMarker"))},A.prototype.onSelectionChange=function(E){var O=this.session;if(O.$selectionMarker&&O.removeMarker(O.$selectionMarker),O.$selectionMarker=null,this.selection.isEmpty())this.$updateHighlightActiveLine();else{var k=this.selection.getRange(),H=this.getSelectionStyle();O.$selectionMarker=O.addMarker(k,"ace_selection",H)}var V=this.$highlightSelectedWord&&this.$getSelectionHighLightRegexp();this.session.highlight(V),this._signal("changeSelection")},A.prototype.$getSelectionHighLightRegexp=function(){var E=this.session,O=this.getSelectionRange();if(!(O.isEmpty()||O.isMultiLine())){var k=O.start.column,H=O.end.column,V=E.getLine(O.start.row),W=V.substring(k,H);if(!(W.length>5e3||!/[\w\d]/.test(W))){var K=this.$search.$assembleRegExp({wholeWord:!0,caseSensitive:!0,needle:W}),Q=V.substring(k-1,H+1);if(K.test(Q))return K}}},A.prototype.onChangeFrontMarker=function(){this.renderer.updateFrontMarkers()},A.prototype.onChangeBackMarker=function(){this.renderer.updateBackMarkers()},A.prototype.onChangeBreakpoint=function(){this.renderer.updateBreakpoints()},A.prototype.onChangeAnnotation=function(){this.renderer.setAnnotations(this.session.getAnnotations())},A.prototype.onChangeMode=function(E){this.renderer.updateText(),this._emit("changeMode",E)},A.prototype.onChangeWrapLimit=function(){this.renderer.updateFull()},A.prototype.onChangeWrapMode=function(){this.renderer.onResize(!0)},A.prototype.onChangeFold=function(){this.$updateHighlightActiveLine(),this.renderer.updateFull()},A.prototype.getSelectedText=function(){return this.session.getTextRange(this.getSelectionRange())},A.prototype.getCopyText=function(){var E=this.getSelectedText(),O=this.session.doc.getNewLineCharacter(),k=!1;if(!E&&this.$copyWithEmptySelection){k=!0;for(var H=this.selection.getAllRanges(),V=0;VY.search(/\S|$/)){var Q=Y.substr(V.column).search(/\S|$/);k.doc.removeInLine(V.row,V.column,V.column+Q)}}this.clearSelection();var ie=V.column,J=k.getState(V.row),Y=k.getLine(V.row),z=H.checkOutdent(J,Y,E);if(k.insert(V,E),W&&W.selection&&(W.selection.length==2?this.selection.setSelectionRange(new g(V.row,ie+W.selection[0],V.row,ie+W.selection[1])):this.selection.setSelectionRange(new g(V.row+W.selection[0],W.selection[1],V.row+W.selection[2],W.selection[3]))),this.$enableAutoIndent){if(k.getDocument().isNewLine(E)){var oe=H.getNextLineIndent(J,Y.slice(0,V.column),k.getTabString());k.insert({row:V.row+1,column:0},oe)}z&&H.autoOutdent(J,k,V.row)}},A.prototype.autoIndent=function(){var E=this.session,O=E.getMode(),k,H;if(this.selection.isEmpty())k=0,H=E.doc.getLength()-1;else{var V=this.getSelectionRange();k=V.start.row,H=V.end.row}for(var W="",K="",Q="",ie,J,Y,z=E.getTabString(),oe=k;oe<=H;oe++)oe>0&&(W=E.getState(oe-1),K=E.getLine(oe-1),Q=O.getNextLineIndent(W,K,z)),ie=E.getLine(oe),J=O.$getIndent(ie),Q!==J&&(J.length>0&&(Y=new g(oe,0,oe,J.length),E.remove(Y)),Q.length>0&&E.insert({row:oe,column:0},Q)),O.autoOutdent(W,E,oe)},A.prototype.onTextInput=function(E,O){if(!O)return this.keyBinding.onTextInput(E);this.startOperation({command:{name:"insertstring"}});var k=this.applyComposition.bind(this,E,O);this.selection.rangeCount?this.forEachSelection(k):k(),this.endOperation()},A.prototype.applyComposition=function(E,O){if(O.extendLeft||O.extendRight){var k=this.selection.getRange();k.start.column-=O.extendLeft,k.end.column+=O.extendRight,k.start.column<0&&(k.start.row--,k.start.column+=this.session.getLine(k.start.row).length+1),this.selection.setRange(k),!E&&!k.isEmpty()&&this.remove()}if((E||!this.selection.isEmpty())&&this.insert(E,!0),O.restoreStart||O.restoreEnd){var k=this.selection.getRange();k.start.column-=O.restoreStart,k.end.column-=O.restoreEnd,this.selection.setRange(k)}},A.prototype.onCommandKey=function(E,O,k){return this.keyBinding.onCommandKey(E,O,k)},A.prototype.setOverwrite=function(E){this.session.setOverwrite(E)},A.prototype.getOverwrite=function(){return this.session.getOverwrite()},A.prototype.toggleOverwrite=function(){this.session.toggleOverwrite()},A.prototype.setScrollSpeed=function(E){this.setOption("scrollSpeed",E)},A.prototype.getScrollSpeed=function(){return this.getOption("scrollSpeed")},A.prototype.setDragDelay=function(E){this.setOption("dragDelay",E)},A.prototype.getDragDelay=function(){return this.getOption("dragDelay")},A.prototype.setSelectionStyle=function(E){this.setOption("selectionStyle",E)},A.prototype.getSelectionStyle=function(){return this.getOption("selectionStyle")},A.prototype.setHighlightActiveLine=function(E){this.setOption("highlightActiveLine",E)},A.prototype.getHighlightActiveLine=function(){return this.getOption("highlightActiveLine")},A.prototype.setHighlightGutterLine=function(E){this.setOption("highlightGutterLine",E)},A.prototype.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},A.prototype.setHighlightSelectedWord=function(E){this.setOption("highlightSelectedWord",E)},A.prototype.getHighlightSelectedWord=function(){return this.$highlightSelectedWord},A.prototype.setAnimatedScroll=function(E){this.renderer.setAnimatedScroll(E)},A.prototype.getAnimatedScroll=function(){return this.renderer.getAnimatedScroll()},A.prototype.setShowInvisibles=function(E){this.renderer.setShowInvisibles(E)},A.prototype.getShowInvisibles=function(){return this.renderer.getShowInvisibles()},A.prototype.setDisplayIndentGuides=function(E){this.renderer.setDisplayIndentGuides(E)},A.prototype.getDisplayIndentGuides=function(){return this.renderer.getDisplayIndentGuides()},A.prototype.setHighlightIndentGuides=function(E){this.renderer.setHighlightIndentGuides(E)},A.prototype.getHighlightIndentGuides=function(){return this.renderer.getHighlightIndentGuides()},A.prototype.setShowPrintMargin=function(E){this.renderer.setShowPrintMargin(E)},A.prototype.getShowPrintMargin=function(){return this.renderer.getShowPrintMargin()},A.prototype.setPrintMarginColumn=function(E){this.renderer.setPrintMarginColumn(E)},A.prototype.getPrintMarginColumn=function(){return this.renderer.getPrintMarginColumn()},A.prototype.setReadOnly=function(E){this.setOption("readOnly",E)},A.prototype.getReadOnly=function(){return this.getOption("readOnly")},A.prototype.setBehavioursEnabled=function(E){this.setOption("behavioursEnabled",E)},A.prototype.getBehavioursEnabled=function(){return this.getOption("behavioursEnabled")},A.prototype.setWrapBehavioursEnabled=function(E){this.setOption("wrapBehavioursEnabled",E)},A.prototype.getWrapBehavioursEnabled=function(){return this.getOption("wrapBehavioursEnabled")},A.prototype.setShowFoldWidgets=function(E){this.setOption("showFoldWidgets",E)},A.prototype.getShowFoldWidgets=function(){return this.getOption("showFoldWidgets")},A.prototype.setFadeFoldWidgets=function(E){this.setOption("fadeFoldWidgets",E)},A.prototype.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},A.prototype.remove=function(E){this.selection.isEmpty()&&(E=="left"?this.selection.selectLeft():this.selection.selectRight());var O=this.getSelectionRange();if(this.getBehavioursEnabled()){var k=this.session,H=k.getState(O.start.row),V=k.getMode().transformAction(H,"deletion",this,k,O);if(O.end.column===0){var W=k.getTextRange(O);if(W[W.length-1]==` +`){var K=k.getLine(O.end.row);/^\s+$/.test(K)&&(O.end.column=K.length)}}V&&(O=V)}this.session.remove(O),this.clearSelection()},A.prototype.removeWordRight=function(){this.selection.isEmpty()&&this.selection.selectWordRight(),this.session.remove(this.getSelectionRange()),this.clearSelection()},A.prototype.removeWordLeft=function(){this.selection.isEmpty()&&this.selection.selectWordLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},A.prototype.removeToLineStart=function(){this.selection.isEmpty()&&this.selection.selectLineStart(),this.selection.isEmpty()&&this.selection.selectLeft(),this.session.remove(this.getSelectionRange()),this.clearSelection()},A.prototype.removeToLineEnd=function(){this.selection.isEmpty()&&this.selection.selectLineEnd();var E=this.getSelectionRange();E.start.column==E.end.column&&E.start.row==E.end.row&&(E.end.column=0,E.end.row++),this.session.remove(E),this.clearSelection()},A.prototype.splitLine=function(){this.selection.isEmpty()||(this.session.remove(this.getSelectionRange()),this.clearSelection());var E=this.getCursorPosition();this.insert(` +`),this.moveCursorToPosition(E)},A.prototype.setGhostText=function(E,O){this.session.widgetManager||(this.session.widgetManager=new w(this.session),this.session.widgetManager.attach(this)),this.renderer.setGhostText(E,O)},A.prototype.removeGhostText=function(){this.session.widgetManager&&this.renderer.removeGhostText()},A.prototype.transposeLetters=function(){if(this.selection.isEmpty()){var E=this.getCursorPosition(),O=E.column;if(O!==0){var k=this.session.getLine(E.row),H,V;OQ.toLowerCase()?1:0});for(var V=new g(0,0,0,0),H=E.first;H<=E.last;H++){var W=O.getLine(H);V.start.row=H,V.end.row=H,V.end.column=W.length,O.replace(V,k[H-E.first])}},A.prototype.toggleCommentLines=function(){var E=this.session.getState(this.getCursorPosition().row),O=this.$getSelectedRows();this.session.getMode().toggleCommentLines(E,this.session,O.first,O.last)},A.prototype.toggleBlockComment=function(){var E=this.getCursorPosition(),O=this.session.getState(E.row),k=this.getSelectionRange();this.session.getMode().toggleBlockComment(O,this.session,k,E)},A.prototype.getNumberAt=function(E,O){var k=/[\-]?[0-9]+(?:\.[0-9]+)?/g;k.lastIndex=0;for(var H=this.session.getLine(E);k.lastIndex=O){var W={value:V[0],start:V.index,end:V.index+V[0].length};return W}}return null},A.prototype.modifyNumber=function(E){var O=this.selection.getCursor().row,k=this.selection.getCursor().column,H=new g(O,k-1,O,k),V=this.session.getTextRange(H);if(!isNaN(parseFloat(V))&&isFinite(V)){var W=this.getNumberAt(O,k);if(W){var K=W.value.indexOf(".")>=0?W.start+W.value.indexOf(".")+1:W.end,Q=W.start+W.value.length-K,ie=parseFloat(W.value);ie*=Math.pow(10,Q),K!==W.end&&k=K&&W<=Q&&(k=Re,ie.selection.clearSelection(),ie.moveCursorTo(E,K+H),ie.selection.selectTo(E,Q+H)),K=Q});for(var J=this.$toggleWordPairs,Y,z=0;z=Q&&K<=ie&&oe.match(/((?:https?|ftp):\/\/[\S]+)/)){J=oe.replace(/[\s:.,'";}\]]+$/,"");break}Q=ie}}catch(he){k={error:he}}finally{try{z&&!z.done&&(H=Y.return)&&H.call(Y)}finally{if(k)throw k.error}}return J},A.prototype.openLink=function(){var E=this.selection.getCursor(),O=this.findLinkAt(E.row,E.column);return O&&window.open(O,"_blank"),O!=null},A.prototype.removeLines=function(){var E=this.$getSelectedRows();this.session.removeFullLines(E.first,E.last),this.clearSelection()},A.prototype.duplicateSelection=function(){var E=this.selection,O=this.session,k=E.getRange(),H=E.isBackwards();if(k.isEmpty()){var V=k.start.row;O.duplicateLines(V,V)}else{var W=H?k.start:k.end,K=O.insert(W,O.getTextRange(k),!1);k.start=W,k.end=K,E.setSelectionRange(k,H)}},A.prototype.moveLinesDown=function(){this.$moveLines(1,!1)},A.prototype.moveLinesUp=function(){this.$moveLines(-1,!1)},A.prototype.moveText=function(E,O,k){return this.session.moveText(E,O,k)},A.prototype.copyLinesUp=function(){this.$moveLines(-1,!0)},A.prototype.copyLinesDown=function(){this.$moveLines(1,!0)},A.prototype.$moveLines=function(E,O){var k,H,V=this.selection;if(!V.inMultiSelectMode||this.inVirtualSelectionMode){var W=V.toOrientedRange();k=this.$getSelectedRows(W),H=this.session.$moveLines(k.first,k.last,O?0:E),O&&E==-1&&(H=0),W.moveBy(H,0),V.fromOrientedRange(W)}else{var K=V.rangeList.ranges;V.rangeList.detach(this.session),this.inVirtualSelectionMode=!0;for(var Q=0,ie=0,J=K.length,Y=0;Yhe+1)break;he=de.last}for(Y--,Q=this.session.$moveLines(oe,he,O?0:E),O&&E==-1&&(z=Y+1);z<=Y;)K[z].moveBy(Q,0),z++;O||(Q=0),ie+=Q}V.fromOrientedRange(V.ranges[0]),V.rangeList.attach(this.session),this.inVirtualSelectionMode=!1}},A.prototype.$getSelectedRows=function(E){return E=(E||this.getSelectionRange()).collapseRows(),{first:this.session.getRowFoldStart(E.start.row),last:this.session.getRowFoldEnd(E.end.row)}},A.prototype.onCompositionStart=function(E){this.renderer.showComposition(E)},A.prototype.onCompositionUpdate=function(E){this.renderer.setCompositionText(E)},A.prototype.onCompositionEnd=function(){this.renderer.hideComposition()},A.prototype.getFirstVisibleRow=function(){return this.renderer.getFirstVisibleRow()},A.prototype.getLastVisibleRow=function(){return this.renderer.getLastVisibleRow()},A.prototype.isRowVisible=function(E){return E>=this.getFirstVisibleRow()&&E<=this.getLastVisibleRow()},A.prototype.isRowFullyVisible=function(E){return E>=this.renderer.getFirstFullyVisibleRow()&&E<=this.renderer.getLastFullyVisibleRow()},A.prototype.$getVisibleRowCount=function(){return this.renderer.getScrollBottomRow()-this.renderer.getScrollTopRow()+1},A.prototype.$moveByPage=function(E,O){var k=this.renderer,H=this.renderer.layerConfig,V=E*Math.floor(H.height/H.lineHeight);O===!0?this.selection.$moveSelection(function(){this.moveCursorBy(V,0)}):O===!1&&(this.selection.moveCursorBy(V,0),this.selection.clearSelection());var W=k.scrollTop;k.scrollBy(0,V*H.lineHeight),O!=null&&k.scrollCursorIntoView(null,.5),k.animateScrolling(W)},A.prototype.selectPageDown=function(){this.$moveByPage(1,!0)},A.prototype.selectPageUp=function(){this.$moveByPage(-1,!0)},A.prototype.gotoPageDown=function(){this.$moveByPage(1,!1)},A.prototype.gotoPageUp=function(){this.$moveByPage(-1,!1)},A.prototype.scrollPageDown=function(){this.$moveByPage(1)},A.prototype.scrollPageUp=function(){this.$moveByPage(-1)},A.prototype.scrollToRow=function(E){this.renderer.scrollToRow(E)},A.prototype.scrollToLine=function(E,O,k,H){this.renderer.scrollToLine(E,O,k,H)},A.prototype.centerSelection=function(){var E=this.getSelectionRange(),O={row:Math.floor(E.start.row+(E.end.row-E.start.row)/2),column:Math.floor(E.start.column+(E.end.column-E.start.column)/2)};this.renderer.alignCursor(O,.5)},A.prototype.getCursorPosition=function(){return this.selection.getCursor()},A.prototype.getCursorPositionScreen=function(){return this.session.documentToScreenPosition(this.getCursorPosition())},A.prototype.getSelectionRange=function(){return this.selection.getRange()},A.prototype.selectAll=function(){this.selection.selectAll()},A.prototype.clearSelection=function(){this.selection.clearSelection()},A.prototype.moveCursorTo=function(E,O){this.selection.moveCursorTo(E,O)},A.prototype.moveCursorToPosition=function(E){this.selection.moveCursorToPosition(E)},A.prototype.jumpToMatching=function(E,O){var k=this.getCursorPosition(),H=new I(this.session,k.row,k.column),V=H.getCurrentToken(),W=0;V&&V.type.indexOf("tag-name")!==-1&&(V=H.stepBackward());var K=V||H.stepForward();if(K){var Q,ie=!1,J={},Y=k.column-K.start,z,oe={")":"(","(":"(","]":"[","[":"[","{":"{","}":"{"};do{if(K.value.match(/[{}()\[\]]/g)){for(;Y1?J[K.value]++:V.value==="=0;--W)this.$tryReplace(k[W],E)&&H++;return this.selection.setSelectionRange(V),H},A.prototype.$tryReplace=function(E,O){var k=this.session.getTextRange(E);return O=this.$search.replace(k,O),O!==null?(E.end=this.session.replace(E,O),E):null},A.prototype.getLastSearchOptions=function(){return this.$search.getOptions()},A.prototype.find=function(E,O,k){O||(O={}),typeof E=="string"||E instanceof RegExp?O.needle=E:typeof E=="object"&&P.mixin(O,E);var H=this.selection.getRange();O.needle==null&&(E=this.session.getTextRange(H)||this.$search.$options.needle,E||(H=this.session.getWordRange(H.start.row,H.start.column),E=this.session.getTextRange(H)),this.$search.set({needle:E})),this.$search.set(O),O.start||this.$search.set({start:H});var V=this.$search.find(this.session);if(O.preventScroll)return V;if(V)return this.revealRange(V,k),V;O.backwards?H.start=H.end:H.end=H.start,this.selection.setRange(H)},A.prototype.findNext=function(E,O){this.find({skipCurrent:!0,backwards:!1},E,O)},A.prototype.findPrevious=function(E,O){this.find(E,{skipCurrent:!0,backwards:!0},O)},A.prototype.revealRange=function(E,O){this.session.unfold(E),this.selection.setSelectionRange(E);var k=this.renderer.scrollTop;this.renderer.scrollSelectionIntoView(E.start,E.end,.5),O!==!1&&this.renderer.animateScrolling(k)},A.prototype.undo=function(){this.session.getUndoManager().undo(this.session),this.renderer.scrollCursorIntoView(null,.5)},A.prototype.redo=function(){this.session.getUndoManager().redo(this.session),this.renderer.scrollCursorIntoView(null,.5)},A.prototype.destroy=function(){this.$toDestroy&&(this.$toDestroy.forEach(function(E){E.destroy()}),this.$toDestroy=null),this.$mouseHandler&&this.$mouseHandler.destroy(),this.renderer.destroy(),this._signal("destroy",this),this.session&&this.session.destroy(),this._$emitInputEvent&&this._$emitInputEvent.cancel(),this.removeAllListeners()},A.prototype.setAutoScrollEditorIntoView=function(E){if(E){var O,k=this,H=!1;this.$scrollAnchor||(this.$scrollAnchor=document.createElement("div"));var V=this.$scrollAnchor;V.style.cssText="position:absolute",this.container.insertBefore(V,this.container.firstChild);var W=this.on("changeSelection",function(){H=!0}),K=this.renderer.on("beforeRender",function(){H&&(O=k.renderer.container.getBoundingClientRect())}),Q=this.renderer.on("afterRender",function(){if(H&&O&&(k.isFocused()||k.searchBox&&k.searchBox.isFocused())){var ie=k.renderer,J=ie.$cursorLayer.$pixelPos,Y=ie.layerConfig,z=J.top-Y.offset;J.top>=0&&z+O.top<0?H=!0:J.topwindow.innerHeight?H=!1:H=null,H!=null&&(V.style.top=z+"px",V.style.left=J.left+"px",V.style.height=Y.lineHeight+"px",V.scrollIntoView(H)),H=O=null}});this.setAutoScrollEditorIntoView=function(ie){ie||(delete this.setAutoScrollEditorIntoView,this.off("changeSelection",W),this.renderer.off("afterRender",Q),this.renderer.off("beforeRender",K))}}},A.prototype.$resetCursorStyle=function(){var E=this.$cursorStyle||"ace",O=this.renderer.$cursorLayer;O&&(O.setSmoothBlinking(/smooth/.test(E)),O.isBlinking=!this.$readOnly&&E!="wide",C.setCssClass(O.element,"ace_slim-cursors",/slim/.test(E)))},A.prototype.prompt=function(E,O,k){var H=this;y.loadModule("ace/ext/prompt",function(V){V.prompt(H,E,O,k)})},A}();S.$uid=0,S.prototype.curOp=null,S.prototype.prevOp={},S.prototype.$mergeableCommands=["backspace","del","insertstring"],S.prototype.$toggleWordPairs=[["first","last"],["true","false"],["yes","no"],["width","height"],["top","bottom"],["right","left"],["on","off"],["x","y"],["get","set"],["max","min"],["horizontal","vertical"],["show","hide"],["add","remove"],["up","down"],["before","after"],["even","odd"],["in","out"],["inside","outside"],["next","previous"],["increase","decrease"],["attach","detach"],["&&","||"],["==","!="]],P.implement(S.prototype,_),y.defineOptions(S.prototype,"editor",{selectionStyle:{set:function(A){this.onSelectionChange(),this._signal("changeSelectionStyle",{data:A})},initialValue:"line"},highlightActiveLine:{set:function(){this.$updateHighlightActiveLine()},initialValue:!0},highlightSelectedWord:{set:function(A){this.$onSelectionChange()},initialValue:!0},readOnly:{set:function(A){this.textInput.setReadOnly(A),this.$resetCursorStyle()},initialValue:!1},copyWithEmptySelection:{set:function(A){this.textInput.setCopyWithEmptySelection(A)},initialValue:!1},cursorStyle:{set:function(A){this.$resetCursorStyle()},values:["ace","slim","smooth","wide"],initialValue:"ace"},mergeUndoDeltas:{values:[!1,!0,"always"],initialValue:!0},behavioursEnabled:{initialValue:!0},wrapBehavioursEnabled:{initialValue:!0},enableAutoIndent:{initialValue:!0},autoScrollEditorIntoView:{set:function(A){this.setAutoScrollEditorIntoView(A)}},keyboardHandler:{set:function(A){this.setKeyboardHandler(A)},get:function(){return this.$keybindingId},handlesSet:!0},value:{set:function(A){this.session.setValue(A)},get:function(){return this.getValue()},handlesSet:!0,hidden:!0},session:{set:function(A){this.setSession(A)},get:function(){return this.session},handlesSet:!0,hidden:!0},showLineNumbers:{set:function(A){this.renderer.$gutterLayer.setShowLineNumbers(A),this.renderer.$loop.schedule(this.renderer.CHANGE_GUTTER),A&&this.$relativeLineNumbers?F.attach(this):F.detach(this)},initialValue:!0},relativeLineNumbers:{set:function(A){this.$showLineNumbers&&A?F.attach(this):F.detach(this)}},placeholder:{set:function(A){this.$updatePlaceholder||(this.$updatePlaceholder=function(){var E=this.session&&(this.renderer.$composition||this.session.getLength()>1||this.session.getLine(0).length>0);if(E&&this.renderer.placeholderNode)this.renderer.off("afterRender",this.$updatePlaceholder),C.removeCssClass(this.container,"ace_hasPlaceholder"),this.renderer.placeholderNode.remove(),this.renderer.placeholderNode=null;else if(!E&&!this.renderer.placeholderNode){this.renderer.on("afterRender",this.$updatePlaceholder),C.addCssClass(this.container,"ace_hasPlaceholder");var O=C.createElement("div");O.className="ace_placeholder",O.textContent=this.$placeholder||"",this.renderer.placeholderNode=O,this.renderer.content.appendChild(this.renderer.placeholderNode)}else!E&&this.renderer.placeholderNode&&(this.renderer.placeholderNode.textContent=this.$placeholder||"")}.bind(this),this.on("input",this.$updatePlaceholder)),this.$updatePlaceholder()}},enableKeyboardAccessibility:{set:function(A){var E={name:"blurTextInput",description:"Set focus to the editor content div to allow tabbing through the page",bindKey:"Esc",exec:function(H){H.blur(),H.renderer.scroller.focus()},readOnly:!0},O=function(H){if(H.target==this.renderer.scroller&&H.keyCode===R.enter){H.preventDefault();var V=this.getCursorPosition().row;this.isRowVisible(V)||this.scrollToLine(V,!0,!0),this.focus()}},k;A?(this.renderer.enableKeyboardAccessibility=!0,this.renderer.keyboardFocusClassName="ace_keyboard-focus",this.textInput.getElement().setAttribute("tabindex",-1),this.renderer.scroller.setAttribute("tabindex",0),this.renderer.scroller.setAttribute("role","group"),this.renderer.scroller.setAttribute("aria-roledescription",N("editor")),this.renderer.scroller.classList.add(this.renderer.keyboardFocusClassName),this.renderer.scroller.setAttribute("aria-label",N("Editor content, press Enter to start editing, press Escape to exit")),this.renderer.scroller.addEventListener("keyup",O.bind(this)),this.commands.addCommand(E),this.renderer.$gutter.setAttribute("tabindex",0),this.renderer.$gutter.setAttribute("aria-hidden",!1),this.renderer.$gutter.setAttribute("role","group"),this.renderer.$gutter.setAttribute("aria-roledescription",N("editor")),this.renderer.$gutter.setAttribute("aria-label",N("Editor gutter, press Enter to interact with controls using arrow keys, press Escape to exit")),this.renderer.$gutter.classList.add(this.renderer.keyboardFocusClassName),this.renderer.content.setAttribute("aria-hidden",!0),k||(k=new x(this)),k.addListener()):(this.renderer.enableKeyboardAccessibility=!1,this.textInput.getElement().setAttribute("tabindex",0),this.renderer.scroller.setAttribute("tabindex",-1),this.renderer.scroller.removeAttribute("role"),this.renderer.scroller.removeAttribute("aria-roledescription"),this.renderer.scroller.classList.remove(this.renderer.keyboardFocusClassName),this.renderer.scroller.removeAttribute("aria-label"),this.renderer.scroller.removeEventListener("keyup",O.bind(this)),this.commands.removeCommand(E),this.renderer.content.removeAttribute("aria-hidden"),this.renderer.$gutter.setAttribute("tabindex",-1),this.renderer.$gutter.setAttribute("aria-hidden",!0),this.renderer.$gutter.removeAttribute("role"),this.renderer.$gutter.removeAttribute("aria-roledescription"),this.renderer.$gutter.removeAttribute("aria-label"),this.renderer.$gutter.classList.remove(this.renderer.keyboardFocusClassName),k&&k.removeListener())},initialValue:!1},customScrollbar:"renderer",hScrollBarAlwaysVisible:"renderer",vScrollBarAlwaysVisible:"renderer",highlightGutterLine:"renderer",animatedScroll:"renderer",showInvisibles:"renderer",showPrintMargin:"renderer",printMarginColumn:"renderer",printMargin:"renderer",fadeFoldWidgets:"renderer",showFoldWidgets:"renderer",displayIndentGuides:"renderer",highlightIndentGuides:"renderer",showGutter:"renderer",fontSize:"renderer",fontFamily:"renderer",maxLines:"renderer",minLines:"renderer",scrollPastEnd:"renderer",fixedWidthGutter:"renderer",theme:"renderer",hasCssTransforms:"renderer",maxPixelHeight:"renderer",useTextareaForIME:"renderer",useResizeObserver:"renderer",useSvgGutterIcons:"renderer",showFoldedAnnotations:"renderer",scrollSpeed:"$mouseHandler",dragDelay:"$mouseHandler",dragEnabled:"$mouseHandler",focusTimeout:"$mouseHandler",tooltipFollowsMouse:"$mouseHandler",firstLineNumber:"session",overwrite:"session",newLineMode:"session",useWorker:"session",useSoftTabs:"session",navigateWithinSoftTabs:"session",tabSize:"session",wrap:"session",indentedSoftWrap:"session",foldStyle:"session",mode:"session"});var F={getText:function(A,E){return(Math.abs(A.selection.lead.row-E)||E+1+(E<9?"·":""))+""},getWidth:function(A,E,O){return Math.max(E.toString().length,(O.lastRow+1).toString().length,2)*O.characterWidth},update:function(A,E){E.renderer.$loop.schedule(E.renderer.CHANGE_GUTTER)},attach:function(A){A.renderer.$gutterLayer.$renderer=this,A.on("changeSelection",this.update),this.update(null,A)},detach:function(A){A.renderer.$gutterLayer.$renderer==this&&(A.renderer.$gutterLayer.$renderer=null),A.off("changeSelection",this.update),this.update(null,A)}};p.Editor=S}),ace.define("ace/undomanager",["require","exports","module","ace/range"],function(s,p,m){var B=function(){function I(){this.$maxRev=0,this.$fromUndo=!1,this.$undoDepth=1/0,this.reset()}return I.prototype.addSession=function(w){this.$session=w},I.prototype.add=function(w,x,N){if(!this.$fromUndo&&w!=this.$lastDelta){if(this.$keepRedoStack||(this.$redoStack.length=0),x===!1||!this.lastDeltas){this.lastDeltas=[];var D=this.$undoStack.length;D>this.$undoDepth-1&&this.$undoStack.splice(0,D-this.$undoDepth+1),this.$undoStack.push(this.lastDeltas),w.id=this.$rev=++this.$maxRev}(w.action=="remove"||w.action=="insert")&&(this.$lastDelta=w),this.lastDeltas.push(w)}},I.prototype.addSelection=function(w,x){this.selections.push({value:w,rev:x||this.$rev})},I.prototype.startNewGroup=function(){return this.lastDeltas=null,this.$rev},I.prototype.markIgnored=function(w,x){x==null&&(x=this.$rev+1);for(var N=this.$undoStack,D=N.length;D--;){var R=N[D][0];if(R.id<=w)break;R.id0},I.prototype.canRedo=function(){return this.$redoStack.length>0},I.prototype.bookmark=function(w){w==null&&(w=this.$rev),this.mark=w},I.prototype.isAtBookmark=function(){return this.$rev===this.mark},I.prototype.toJSON=function(){},I.prototype.fromJSON=function(){},I.prototype.$prettyPrint=function(w){return w?o(w):o(this.$undoStack)+` --- -`+o(this.$redoStack)},S}();B.prototype.hasUndo=B.prototype.canUndo,B.prototype.hasRedo=B.prototype.canRedo,B.prototype.isClean=B.prototype.isAtBookmark,B.prototype.markClean=B.prototype.bookmark;function P(S,b){for(var x=b;x--;){var N=S[x];if(N&&!N[0].ignore){for(;x"+S.end.row+":"+S.end.column}function l(S,b){var x=S.action=="insert",N=b.action=="insert";if(x&&N)if(f(b.start,S.end)>=0)g(b,S,-1);else if(f(b.start,S.start)<=0)g(S,b,1);else return null;else if(x&&!N)if(f(b.start,S.end)>=0)g(b,S,-1);else if(f(b.end,S.start)<=0)g(S,b,-1);else return null;else if(!x&&N)if(f(b.start,S.start)>=0)g(b,S,1);else if(f(b.start,S.start)<=0)g(S,b,1);else return null;else if(!x&&!N)if(f(b.start,S.start)>=0)g(b,S,1);else if(f(b.end,S.start)<=0)g(S,b,-1);else return null;return[b,S]}function h(S,b){for(var x=S.length;x--;)for(var N=0;N=0?g(S,b,-1):(f(S.start,b.start)<=0||g(S,C.fromPoints(b.start,S.start),-1),g(b,S,1));else if(!x&&N)f(b.start,S.end)>=0?g(b,S,-1):(f(b.start,S.start)<=0||g(b,C.fromPoints(S.start,b.start),-1),g(S,b,1));else if(!x&&!N)if(f(b.start,S.end)>=0)g(b,S,-1);else if(f(b.end,S.start)<=0)g(S,b,-1);else{var D,R;return f(S.start,b.start)<0&&(D=S,S=v(S,b.start)),f(S.end,b.end)>0&&(R=v(S,b.end)),_(b.end,S.start,S.end,-1),R&&!D&&(S.lines=R.lines,S.start=R.start,S.end=R.end,R=S),[b,D,R].filter(Boolean)}return[b,S]}function g(S,b,x){_(S.start,b.start,b.end,x),_(S.end,b.start,b.end,x)}function _(S,b,x,N){S.row==(N==1?b:x).row&&(S.column+=N*(x.column-b.column)),S.row+=N*(x.row-b.row)}function v(S,b){var x=S.lines,N=S.end;S.end=a(b);var D=S.end.row-S.start.row,R=x.splice(D,x.length),w=D?b.column:b.column-S.start.column;x.push(R[0].substring(0,w)),R[0]=R[0].substr(w);var F={start:a(b),end:N,lines:R,action:S.action};return F}function k(S,b){b=s(b);for(var x=S.length;x--;){for(var N=S[x],D=0;Dk&&(b=v.end.row+1,v=d.getNextFoldLine(b,v),k=v?v.start.row:1/0),b>_){for(;this.$lines.getLength()>S+1;)this.$lines.pop();break}I=this.$lines.get(++S),I?I.row=b:(I=this.$lines.createCell(b,h,this.session,c),this.$lines.push(I)),this.$renderCell(I,h,v,b),b++}this._signal("afterRender"),this.$updateGutterWidth(h)},l.prototype.$updateGutterWidth=function(h){var d=this.session,g=d.gutterRenderer||this.$renderer,_=d.$firstLineNumber,v=this.$lines.last()?this.$lines.last().text:"";(this.$fixedWidth||d.$useWrapMode)&&(v=d.getLength()+_-1);var k=g?g.getWidth(d,v,h):v.toString().length*h.characterWidth,I=this.$padding||this.$computePadding();k+=I.left+I.right,k!==this.gutterWidth&&!isNaN(k)&&(this.gutterWidth=k,this.element.parentNode.style.width=this.element.style.width=Math.ceil(this.gutterWidth)+"px",this._signal("changeGutterWidth",k))},l.prototype.$updateCursorRow=function(){if(this.$highlightGutterLine){var h=this.session.selection.getCursor();this.$cursorRow!==h.row&&(this.$cursorRow=h.row)}},l.prototype.updateLineHighlight=function(){if(this.$highlightGutterLine){var h=this.session.selection.cursor.row;if(this.$cursorRow=h,!(this.$cursorCell&&this.$cursorCell.row==h)){this.$cursorCell&&(this.$cursorCell.element.className=this.$cursorCell.element.className.replace("ace_gutter-active-line ",""));var d=this.$lines.cells;this.$cursorCell=null;for(var g=0;g=this.$cursorRow){if(_.row>this.$cursorRow){var v=this.session.getFoldLine(this.$cursorRow);if(g>0&&v&&v.start.row==d[g-1].row)_=d[g-1];else break}_.element.className="ace_gutter-active-line "+_.element.className,this.$cursorCell=_;break}}}}},l.prototype.scrollLines=function(h){var d=this.config;if(this.config=h,this.$updateCursorRow(),this.$lines.pageChanged(d,h))return this.update(h);this.$lines.moveContainer(h);var g=Math.min(h.lastRow+h.gutterOffset,this.session.getLength()-1),_=this.oldLastRow;if(this.oldLastRow=g,!d||_0;v--)this.$lines.shift();if(_>g)for(var v=this.session.getFoldedRowCount(g+1,_);v>0;v--)this.$lines.pop();h.firstRow_&&this.$lines.push(this.$renderLines(h,_+1,g)),this.updateLineHighlight(),this._signal("afterRender"),this.$updateGutterWidth(h)},l.prototype.$renderLines=function(h,d,g){for(var _=[],v=d,k=this.session.getNextFoldLine(v),I=k?k.start.row:1/0;v>I&&(v=k.end.row+1,k=this.session.getNextFoldLine(v,k),I=k?k.start.row:1/0),!(v>g);){var S=this.$lines.createCell(v,h,this.session,c);this.$renderCell(S,h,k,v),_.push(S),v++}return _},l.prototype.$renderCell=function(h,d,g,_){var v=h.element,k=this.session,I=v.childNodes[0],S=v.childNodes[1],b=v.childNodes[2],x=b.firstChild,N=k.$firstLineNumber,D=k.$breakpoints,R=k.$decorations,w=k.gutterRenderer||this.$renderer,F=this.$showFoldWidgets&&k.foldWidgets,A=g?g.start.row:Number.MAX_VALUE,T=d.lineHeight+"px",L=this.$useSvgGutterIcons?"ace_gutter-cell_svg-icons ":"ace_gutter-cell ",O=this.$useSvgGutterIcons?"ace_icon_svg":"ace_icon",H=(w?w.getText(k,_):_+N).toString();if(this.$highlightGutterLine&&(_==this.$cursorRow||g&&_=A&&this.$cursorRow<=g.end.row)&&(L+="ace_gutter-active-line ",this.$cursorCell!=h&&(this.$cursorCell&&(this.$cursorCell.element.className=this.$cursorCell.element.className.replace("ace_gutter-active-line ","")),this.$cursorCell=h)),D[_]&&(L+=D[_]),R[_]&&(L+=R[_]),this.$annotations[_]&&_!==A&&(L+=this.$annotations[_].className),v.className!=L&&(v.className=L),F){var V=F[_];V==null&&(V=F[_]=k.getFoldWidget(_))}if(V){var L="ace_fold-widget ace_"+V;if(V=="start"&&_==A&&_g.right-d.right)return"foldWidgets"},l}();o.prototype.$fixedWidth=!1,o.prototype.$highlightGutterLine=!0,o.prototype.$renderer="",o.prototype.$showLineNumbers=!0,o.prototype.$showFoldWidgets=!0,P.implement(o.prototype,f);function c(l){var h=document.createTextNode("");l.appendChild(h);var d=B.createElement("span");l.appendChild(d);var g=B.createElement("span");l.appendChild(g);var _=B.createElement("span");return g.appendChild(_),l}p.Gutter=o}),ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"],function(r,p,m){var B=r("../range").Range,P=r("../lib/dom"),C=function(){function a(s){this.element=P.createElement("div"),this.element.className="ace_layer ace_marker-layer",s.appendChild(this.element)}return a.prototype.setPadding=function(s){this.$padding=s},a.prototype.setSession=function(s){this.session=s},a.prototype.setMarkers=function(s){this.markers=s},a.prototype.elt=function(s,o){var c=this.i!=-1&&this.element.childNodes[this.i];c?this.i++:(c=document.createElement("div"),this.element.appendChild(c),this.i=-1),c.style.cssText=o,c.className=s},a.prototype.update=function(s){if(s){this.config=s,this.i=0;var o;for(var c in this.markers){var l=this.markers[c];if(!l.range){l.update(o,this,this.session,s);continue}var h=l.range.clipRows(s.firstRow,s.lastRow);if(!h.isEmpty())if(h=h.toScreenRange(this.session),l.renderer){var d=this.$getTop(h.start.row,s),g=this.$padding+h.start.column*s.characterWidth;l.renderer(o,h,g,d,s)}else l.type=="fullLine"?this.drawFullLineMarker(o,h,l.clazz,s):l.type=="screenLine"?this.drawScreenLineMarker(o,h,l.clazz,s):h.isMultiLine()?l.type=="text"?this.drawTextMarker(o,h,l.clazz,s):this.drawMultiLineMarker(o,h,l.clazz,s):this.drawSingleLineMarker(o,h,l.clazz+" ace_start ace_br15",s)}if(this.i!=-1)for(;this.iS,v==_),l,v==_?0:1,h)},a.prototype.drawMultiLineMarker=function(s,o,c,l,h){var d=this.$padding,g=l.lineHeight,_=this.$getTop(o.start.row,l),v=d+o.start.column*l.characterWidth;if(h=h||"",this.session.$bidiHandler.isBidiRow(o.start.row)){var k=o.clone();k.end.row=k.start.row,k.end.column=this.session.getLine(k.start.row).length,this.drawBidiSingleLineMarker(s,k,c+" ace_br1 ace_start",l,null,h)}else this.elt(c+" ace_br1 ace_start","height:"+g+"px;right:0;top:"+_+"px;left:"+v+"px;"+(h||""));if(this.session.$bidiHandler.isBidiRow(o.end.row)){var k=o.clone();k.start.row=k.end.row,k.start.column=0,this.drawBidiSingleLineMarker(s,k,c+" ace_br12",l,null,h)}else{_=this.$getTop(o.end.row,l);var I=o.end.column*l.characterWidth;this.elt(c+" ace_br12","height:"+g+"px;width:"+I+"px;top:"+_+"px;left:"+d+"px;"+(h||""))}if(g=(o.end.row-o.start.row-1)*l.lineHeight,!(g<=0)){_=this.$getTop(o.start.row+1,l);var S=(o.start.column?1:0)|(o.end.column?0:8);this.elt(c+(S?" ace_br"+S:""),"height:"+g+"px;right:0;top:"+_+"px;left:"+d+"px;"+(h||""))}},a.prototype.drawSingleLineMarker=function(s,o,c,l,h,d){if(this.session.$bidiHandler.isBidiRow(o.start.row))return this.drawBidiSingleLineMarker(s,o,c,l,h,d);var g=l.lineHeight,_=(o.end.column+(h||0)-o.start.column)*l.characterWidth,v=this.$getTop(o.start.row,l),k=this.$padding+o.start.column*l.characterWidth;this.elt(c,"height:"+g+"px;width:"+_+"px;top:"+v+"px;left:"+k+"px;"+(d||""))},a.prototype.drawBidiSingleLineMarker=function(s,o,c,l,h,d){var g=l.lineHeight,_=this.$getTop(o.start.row,l),v=this.$padding,k=this.session.$bidiHandler.getSelections(o.start.column,o.end.column);k.forEach(function(I){this.elt(c,"height:"+g+"px;width:"+(I.width+(h||0))+"px;top:"+_+"px;left:"+(v+I.left)+"px;"+(d||""))},this)},a.prototype.drawFullLineMarker=function(s,o,c,l,h){var d=this.$getTop(o.start.row,l),g=l.lineHeight;o.start.row!=o.end.row&&(g+=this.$getTop(o.end.row,l)-d),this.elt(c,"height:"+g+"px;top:"+d+"px;left:0;right:0;"+(h||""))},a.prototype.drawScreenLineMarker=function(s,o,c,l,h){var d=this.$getTop(o.start.row,l),g=l.lineHeight;this.elt(c,"height:"+g+"px;top:"+d+"px;left:0;right:0;"+(h||""))},a}();C.prototype.$padding=0;function f(a,s,o,c){return(a?1:0)|(s?2:0)|(o?4:0)|(c?8:0)}p.Marker=C}),ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/layer/lines","ace/lib/event_emitter","ace/config"],function(r,p,m){var B=r("../lib/oop"),P=r("../lib/dom"),C=r("../lib/lang"),f=r("./lines").Lines,a=r("../lib/event_emitter").EventEmitter,s=r("../config").nls,o=function(){function c(l){this.dom=P,this.element=this.dom.createElement("div"),this.element.className="ace_layer ace_text-layer",l.appendChild(this.element),this.$updateEolChar=this.$updateEolChar.bind(this),this.$lines=new f(this.element)}return c.prototype.$updateEolChar=function(){var l=this.session.doc,h=l.getNewLineCharacter()==` -`&&l.getNewLineMode()!="windows",d=h?this.EOL_CHAR_LF:this.EOL_CHAR_CRLF;if(this.EOL_CHAR!=d)return this.EOL_CHAR=d,!0},c.prototype.setPadding=function(l){this.$padding=l,this.element.style.margin="0 "+l+"px"},c.prototype.getLineHeight=function(){return this.$fontMetrics.$characterSize.height||0},c.prototype.getCharacterWidth=function(){return this.$fontMetrics.$characterSize.width||0},c.prototype.$setFontMetrics=function(l){this.$fontMetrics=l,this.$fontMetrics.on("changeCharacterSize",function(h){this._signal("changeCharacterSize",h)}.bind(this)),this.$pollSizeChanges()},c.prototype.checkForSizeChanges=function(){this.$fontMetrics.checkForSizeChanges()},c.prototype.$pollSizeChanges=function(){return this.$pollSizeChangesTimer=this.$fontMetrics.$pollSizeChanges()},c.prototype.setSession=function(l){this.session=l,l&&this.$computeTabString()},c.prototype.setShowInvisibles=function(l){return this.showInvisibles==l?!1:(this.showInvisibles=l,typeof l=="string"?(this.showSpaces=/tab/i.test(l),this.showTabs=/space/i.test(l),this.showEOL=/eol/i.test(l)):this.showSpaces=this.showTabs=this.showEOL=l,this.$computeTabString(),!0)},c.prototype.setDisplayIndentGuides=function(l){return this.displayIndentGuides==l?!1:(this.displayIndentGuides=l,this.$computeTabString(),!0)},c.prototype.setHighlightIndentGuides=function(l){return this.$highlightIndentGuides===l?!1:(this.$highlightIndentGuides=l,l)},c.prototype.$computeTabString=function(){var l=this.session.getTabSize();this.tabSize=l;for(var h=this.$tabStrings=[0],d=1;dx&&(S=b.end.row+1,b=this.session.getNextFoldLine(S,b),x=b?b.start.row:1/0),!(S>_);){var N=v[k++];if(N){this.dom.removeChildren(N),this.$renderLine(N,S,S==x?b:!1),I&&(N.style.top=this.$lines.computeLineTop(S,l,this.session)+"px");var D=l.lineHeight*this.session.getRowLength(S)+"px";N.style.height!=D&&(I=!0,N.style.height=D)}S++}if(I)for(;k0;_--)this.$lines.shift();if(h.lastRow>l.lastRow)for(var _=this.session.getFoldedRowCount(l.lastRow+1,h.lastRow);_>0;_--)this.$lines.pop();l.firstRowh.lastRow&&this.$lines.push(this.$renderLinesFragment(l,h.lastRow+1,l.lastRow)),this.$highlightIndentGuide()},c.prototype.$renderLinesFragment=function(l,h,d){for(var g=[],_=h,v=this.session.getNextFoldLine(_),k=v?v.start.row:1/0;_>k&&(_=v.end.row+1,v=this.session.getNextFoldLine(_,v),k=v?v.start.row:1/0),!(_>d);){var I=this.$lines.createCell(_,l,this.session),S=I.element;this.dom.removeChildren(S),P.setStyle(S.style,"height",this.$lines.computeLineHeight(_,l,this.session)+"px"),P.setStyle(S.style,"top",this.$lines.computeLineTop(_,l,this.session)+"px"),this.$renderLine(S,_,_==k?v:!1),this.$useLineGroups()?S.className="ace_line_group":S.className="ace_line",g.push(I),_++}return g},c.prototype.update=function(l){this.$lines.moveContainer(l),this.config=l;for(var h=l.firstRow,d=l.lastRow,g=this.$lines;g.getLength();)g.pop();g.push(this.$renderLinesFragment(l,h,d))},c.prototype.$renderToken=function(l,h,d,g){for(var _=this,v=/(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC\u2066\u2067\u2068\u202A\u202B\u202D\u202E\u202C\u2069]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,k=this.dom.createFragment(this.element),I,S=0;I=v.exec(g);){var b=I[1],x=I[2],N=I[3],D=I[4],R=I[5];if(!(!_.showSpaces&&x)){var w=S!=I.index?g.slice(S,I.index):"";if(S=I.index+I[0].length,w&&k.appendChild(this.dom.createTextNode(w,this.element)),b){var F=_.session.getScreenTabSize(h+I.index);k.appendChild(_.$tabStrings[F].cloneNode(!0)),h+=F-1}else if(x)if(_.showSpaces){var A=this.dom.createElement("span");A.className="ace_invisible ace_invisible_space",A.textContent=C.stringRepeat(_.SPACE_CHAR,x.length),k.appendChild(A)}else k.appendChild(this.com.createTextNode(x,this.element));else if(N){var A=this.dom.createElement("span");A.className="ace_invisible ace_invisible_space ace_invalid",A.textContent=C.stringRepeat(_.SPACE_CHAR,N.length),k.appendChild(A)}else if(D){h+=1;var A=this.dom.createElement("span");A.style.width=_.config.characterWidth*2+"px",A.className=_.showSpaces?"ace_cjk ace_invisible ace_invisible_space":"ace_cjk",A.textContent=_.showSpaces?_.SPACE_CHAR:D,k.appendChild(A)}else if(R){h+=1;var A=this.dom.createElement("span");A.style.width=_.config.characterWidth*2+"px",A.className="ace_cjk",A.textContent=R,k.appendChild(A)}}}if(k.appendChild(this.dom.createTextNode(S?g.slice(S):g,this.element)),this.$textToken[d.type])l.appendChild(k);else{var T="ace_"+d.type.replace(/\./g," ace_"),A=this.dom.createElement("span");d.type=="fold"&&(A.style.width=d.value.length*this.config.characterWidth+"px",A.setAttribute("title",s("Unfold code"))),A.className=T,A.appendChild(k),l.appendChild(A)}return h+g.length},c.prototype.renderIndentGuide=function(l,h,d){var g=h.search(this.$indentGuideRe);if(g<=0||g>=d)return h;if(h[0]==" "){g-=g%this.tabSize;for(var _=g/this.tabSize,v=0;v<_;v++)l.appendChild(this.$tabStrings[" "].cloneNode(!0));return this.$highlightIndentGuide(),h.substr(g)}else if(h[0]==" "){for(var v=0;vv[k].start.row?this.$highlightIndentGuideMarker.dir=-1:this.$highlightIndentGuideMarker.dir=1;break}}if(!this.$highlightIndentGuideMarker.end&&l[h.row]!==""&&h.column===l[h.row].length){this.$highlightIndentGuideMarker.dir=1;for(var k=h.row+1;k0){for(var _=0;_=this.$highlightIndentGuideMarker.start+1){if(g.row>=this.$highlightIndentGuideMarker.end)break;this.$setIndentGuideActive(g,h)}}else for(var d=l.length-1;d>=0;d--){var g=l[d];if(this.$highlightIndentGuideMarker.end&&g.row=v;)k=this.$renderToken(I,k,b,x.substring(0,v-g)),x=x.substring(v-g),g=v,I=this.$createLineElement(),l.appendChild(I),I.appendChild(this.dom.createTextNode(C.stringRepeat(" ",d.indent),this.element)),_++,k=0,v=d[_]||Number.MAX_VALUE;x.length!=0&&(g+=x.length,k=this.$renderToken(I,k,b,x))}}d[d.length-1]>this.MAX_LINE_LENGTH&&this.$renderOverflowMessage(I,k,null,"",!0)},c.prototype.$renderSimpleLine=function(l,h){for(var d=0,g=0;gthis.MAX_LINE_LENGTH)return this.$renderOverflowMessage(l,d,_,v);d=this.$renderToken(l,d,_,v)}}},c.prototype.$renderOverflowMessage=function(l,h,d,g,_){d&&this.$renderToken(l,h,d,g.slice(0,this.MAX_LINE_LENGTH-h));var v=this.dom.createElement("span");v.className="ace_inline_button ace_keyword ace_toggle_wrap",v.textContent=_?"":"",l.appendChild(v)},c.prototype.$renderLine=function(l,h,d){if(!d&&d!=!1&&(d=this.session.getFoldLine(h)),d)var g=this.$getFoldLineTokens(h,d);else var g=this.session.getTokens(h);var _=l;if(g.length){var v=this.session.getRowSplitData(h);if(v&&v.length){this.$renderWrappedLine(l,g,v);var _=l.lastChild}else{var _=l;this.$useLineGroups()&&(_=this.$createLineElement(),l.appendChild(_)),this.$renderSimpleLine(_,g)}}else this.$useLineGroups()&&(_=this.$createLineElement(),l.appendChild(_));if(this.showEOL&&_){d&&(h=d.end.row);var k=this.dom.createElement("span");k.className="ace_invisible ace_invisible_eol",k.textContent=h==this.session.getLength()-1?this.EOF_CHAR:this.EOL_CHAR,_.appendChild(k)}},c.prototype.$getFoldLineTokens=function(l,h){var d=this.session,g=[];function _(k,I,S){for(var b=0,x=0;x+k[b].value.lengthS-I&&(N=N.substring(0,S-I)),g.push({type:k[b].type,value:N}),x=I+N.length,b+=1}for(;xS?g.push({type:k[b].type,value:N.substring(0,S-x)}):g.push(k[b]),x+=N.length,b+=1}}var v=d.getTokens(l);return h.walk(function(k,I,S,b,x){k!=null?g.push({type:"fold",value:k}):(x&&(v=d.getTokens(I)),v.length&&_(v,b,S))},h.end.row,this.session.getLine(h.end.row).length),g},c.prototype.$useLineGroups=function(){return this.session.getUseWrapMode()},c}();o.prototype.$textToken={text:!0,rparen:!0,lparen:!0},o.prototype.EOF_CHAR="¶",o.prototype.EOL_CHAR_LF="¬",o.prototype.EOL_CHAR_CRLF="¤",o.prototype.EOL_CHAR=o.prototype.EOL_CHAR_LF,o.prototype.TAB_CHAR="—",o.prototype.SPACE_CHAR="·",o.prototype.$padding=0,o.prototype.MAX_LINE_LENGTH=1e4,o.prototype.showInvisibles=!1,o.prototype.showSpaces=!1,o.prototype.showTabs=!1,o.prototype.showEOL=!1,o.prototype.displayIndentGuides=!0,o.prototype.$highlightIndentGuides=!0,o.prototype.$tabStrings=[],o.prototype.destroy={},o.prototype.onChangeTabSize=o.prototype.$computeTabString,B.implement(o.prototype,a),p.Text=o}),ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"],function(r,p,m){var B=r("../lib/dom"),P=function(){function C(f){this.element=B.createElement("div"),this.element.className="ace_layer ace_cursor-layer",f.appendChild(this.element),this.isVisible=!1,this.isBlinking=!0,this.blinkInterval=1e3,this.smoothBlinking=!1,this.cursors=[],this.cursor=this.addCursor(),B.addCssClass(this.element,"ace_hidden-cursors"),this.$updateCursors=this.$updateOpacity.bind(this)}return C.prototype.$updateOpacity=function(f){for(var a=this.cursors,s=a.length;s--;)B.setStyle(a[s].style,"opacity",f?"":"0")},C.prototype.$startCssAnimation=function(){for(var f=this.cursors,a=f.length;a--;)f[a].style.animationDuration=this.blinkInterval+"ms";this.$isAnimating=!0,setTimeout(function(){this.$isAnimating&&B.addCssClass(this.element,"ace_animate-blinking")}.bind(this))},C.prototype.$stopCssAnimation=function(){this.$isAnimating=!1,B.removeCssClass(this.element,"ace_animate-blinking")},C.prototype.setPadding=function(f){this.$padding=f},C.prototype.setSession=function(f){this.session=f},C.prototype.setBlinking=function(f){f!=this.isBlinking&&(this.isBlinking=f,this.restartTimer())},C.prototype.setBlinkInterval=function(f){f!=this.blinkInterval&&(this.blinkInterval=f,this.restartTimer())},C.prototype.setSmoothBlinking=function(f){f!=this.smoothBlinking&&(this.smoothBlinking=f,B.setCssClass(this.element,"ace_smooth-blinking",f),this.$updateCursors(!0),this.restartTimer())},C.prototype.addCursor=function(){var f=B.createElement("div");return f.className="ace_cursor",this.element.appendChild(f),this.cursors.push(f),f},C.prototype.removeCursor=function(){if(this.cursors.length>1){var f=this.cursors.pop();return f.parentNode.removeChild(f),f}},C.prototype.hideCursor=function(){this.isVisible=!1,B.addCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},C.prototype.showCursor=function(){this.isVisible=!0,B.removeCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},C.prototype.restartTimer=function(){var f=this.$updateCursors;if(clearInterval(this.intervalId),clearTimeout(this.timeoutId),this.$stopCssAnimation(),this.smoothBlinking&&(this.$isSmoothBlinking=!1,B.removeCssClass(this.element,"ace_smooth-blinking")),f(!0),!this.isBlinking||!this.blinkInterval||!this.isVisible){this.$stopCssAnimation();return}if(this.smoothBlinking&&(this.$isSmoothBlinking=!0,setTimeout(function(){this.$isSmoothBlinking&&B.addCssClass(this.element,"ace_smooth-blinking")}.bind(this))),B.HAS_CSS_ANIMATION)this.$startCssAnimation();else{var a=function(){this.timeoutId=setTimeout(function(){f(!1)},.6*this.blinkInterval)}.bind(this);this.intervalId=setInterval(function(){f(!0),a()},this.blinkInterval),a()}},C.prototype.getPixelPosition=function(f,a){if(!this.config||!this.session)return{left:0,top:0};f||(f=this.session.selection.getCursor());var s=this.session.documentToScreenPosition(f),o=this.$padding+(this.session.$bidiHandler.isBidiRow(s.row,f.row)?this.session.$bidiHandler.getPosLeft(s.column):s.column*this.config.characterWidth),c=(s.row-(a?this.config.firstRowScreen:0))*this.config.lineHeight;return{left:o,top:c}},C.prototype.isCursorInView=function(f,a){return f.top>=0&&f.topf.height+f.offset||l.top<0)&&s>1)){var h=this.cursors[o++]||this.addCursor(),d=h.style;this.drawCursor?this.drawCursor(h,l,f,a[s],this.session):this.isCursorInView(l,f)?(B.setStyle(d,"display","block"),B.translate(h,l.left,l.top),B.setStyle(d,"width",Math.round(f.characterWidth)+"px"),B.setStyle(d,"height",f.lineHeight+"px")):B.setStyle(d,"display","none")}}for(;this.cursors.length>o;)this.removeCursor();var g=this.session.getOverwrite();this.$setOverwrite(g),this.$pixelPos=l,this.restartTimer()},C.prototype.$setOverwrite=function(f){f!=this.overwrite&&(this.overwrite=f,f?B.addCssClass(this.element,"ace_overwrite-cursors"):B.removeCssClass(this.element,"ace_overwrite-cursors"))},C.prototype.destroy=function(){clearInterval(this.intervalId),clearTimeout(this.timeoutId)},C}();P.prototype.$padding=0,P.prototype.drawCursor=null,p.Cursor=P}),ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(r,p,m){var B=this&&this.__extends||function(){var h=function(d,g){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,v){_.__proto__=v}||function(_,v){for(var k in v)Object.prototype.hasOwnProperty.call(v,k)&&(_[k]=v[k])},h(d,g)};return function(d,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");h(d,g);function _(){this.constructor=d}d.prototype=g===null?Object.create(g):(_.prototype=g.prototype,new _)}}(),P=r("./lib/oop"),C=r("./lib/dom"),f=r("./lib/event"),a=r("./lib/event_emitter").EventEmitter,s=32768,o=function(){function h(d,g){this.element=C.createElement("div"),this.element.className="ace_scrollbar ace_scrollbar"+g,this.inner=C.createElement("div"),this.inner.className="ace_scrollbar-inner",this.inner.textContent=" ",this.element.appendChild(this.inner),d.appendChild(this.element),this.setVisible(!1),this.skipEvent=!1,f.addListener(this.element,"scroll",this.onScroll.bind(this)),f.addListener(this.element,"mousedown",f.preventDefault)}return h.prototype.setVisible=function(d){this.element.style.display=d?"":"none",this.isVisible=d,this.coeff=1},h}();P.implement(o.prototype,a);var c=function(h){B(d,h);function d(g,_){var v=h.call(this,g,"-v")||this;return v.scrollTop=0,v.scrollHeight=0,_.$scrollbarWidth=v.width=C.scrollbarWidth(g.ownerDocument),v.inner.style.width=v.element.style.width=(v.width||15)+5+"px",v.$minWidth=0,v}return d.prototype.onScroll=function(){if(!this.skipEvent){if(this.scrollTop=this.element.scrollTop,this.coeff!=1){var g=this.element.clientHeight/this.scrollHeight;this.scrollTop=this.scrollTop*(1-g)/(this.coeff-g)}this._emit("scroll",{data:this.scrollTop})}this.skipEvent=!1},d.prototype.getWidth=function(){return Math.max(this.isVisible?this.width:0,this.$minWidth||0)},d.prototype.setHeight=function(g){this.element.style.height=g+"px"},d.prototype.setScrollHeight=function(g){this.scrollHeight=g,g>s?(this.coeff=s/g,g=s):this.coeff!=1&&(this.coeff=1),this.inner.style.height=g+"px"},d.prototype.setScrollTop=function(g){this.scrollTop!=g&&(this.skipEvent=!0,this.scrollTop=g,this.element.scrollTop=g*this.coeff)},d}(o);c.prototype.setInnerHeight=c.prototype.setScrollHeight;var l=function(h){B(d,h);function d(g,_){var v=h.call(this,g,"-h")||this;return v.scrollLeft=0,v.height=_.$scrollbarWidth,v.inner.style.height=v.element.style.height=(v.height||15)+5+"px",v}return d.prototype.onScroll=function(){this.skipEvent||(this.scrollLeft=this.element.scrollLeft,this._emit("scroll",{data:this.scrollLeft})),this.skipEvent=!1},d.prototype.getHeight=function(){return this.isVisible?this.height:0},d.prototype.setWidth=function(g){this.element.style.width=g+"px"},d.prototype.setInnerWidth=function(g){this.inner.style.width=g+"px"},d.prototype.setScrollWidth=function(g){this.inner.style.width=g+"px"},d.prototype.setScrollLeft=function(g){this.scrollLeft!=g&&(this.skipEvent=!0,this.scrollLeft=this.element.scrollLeft=g)},d}(o);p.ScrollBar=c,p.ScrollBarV=c,p.ScrollBarH=l,p.VScrollBar=c,p.HScrollBar=l}),ace.define("ace/scrollbar_custom",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(r,p,m){var B=this&&this.__extends||function(){var l=function(h,d){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,_){g.__proto__=_}||function(g,_){for(var v in _)Object.prototype.hasOwnProperty.call(_,v)&&(g[v]=_[v])},l(h,d)};return function(h,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");l(h,d);function g(){this.constructor=h}h.prototype=d===null?Object.create(d):(g.prototype=d.prototype,new g)}}(),P=r("./lib/oop"),C=r("./lib/dom"),f=r("./lib/event"),a=r("./lib/event_emitter").EventEmitter;C.importCssString(`.ace_editor>.ace_sb-v div, .ace_editor>.ace_sb-h div{ +`+o(this.$redoStack)},I}();B.prototype.hasUndo=B.prototype.canUndo,B.prototype.hasRedo=B.prototype.canRedo,B.prototype.isClean=B.prototype.isAtBookmark,B.prototype.markClean=B.prototype.bookmark;function P(I,w){for(var x=w;x--;){var N=I[x];if(N&&!N[0].ignore){for(;x"+I.end.row+":"+I.end.column}function l(I,w){var x=I.action=="insert",N=w.action=="insert";if(x&&N)if(f(w.start,I.end)>=0)g(w,I,-1);else if(f(w.start,I.start)<=0)g(I,w,1);else return null;else if(x&&!N)if(f(w.start,I.end)>=0)g(w,I,-1);else if(f(w.end,I.start)<=0)g(I,w,-1);else return null;else if(!x&&N)if(f(w.start,I.start)>=0)g(w,I,1);else if(f(w.start,I.start)<=0)g(I,w,1);else return null;else if(!x&&!N)if(f(w.start,I.start)>=0)g(w,I,1);else if(f(w.end,I.start)<=0)g(I,w,-1);else return null;return[w,I]}function h(I,w){for(var x=I.length;x--;)for(var N=0;N=0?g(I,w,-1):(f(I.start,w.start)<=0||g(I,C.fromPoints(w.start,I.start),-1),g(w,I,1));else if(!x&&N)f(w.start,I.end)>=0?g(w,I,-1):(f(w.start,I.start)<=0||g(w,C.fromPoints(I.start,w.start),-1),g(I,w,1));else if(!x&&!N)if(f(w.start,I.end)>=0)g(w,I,-1);else if(f(w.end,I.start)<=0)g(I,w,-1);else{var D,R;return f(I.start,w.start)<0&&(D=I,I=v(I,w.start)),f(I.end,w.end)>0&&(R=v(I,w.end)),_(w.end,I.start,I.end,-1),R&&!D&&(I.lines=R.lines,I.start=R.start,I.end=R.end,R=I),[w,D,R].filter(Boolean)}return[w,I]}function g(I,w,x){_(I.start,w.start,w.end,x),_(I.end,w.start,w.end,x)}function _(I,w,x,N){I.row==(N==1?w:x).row&&(I.column+=N*(x.column-w.column)),I.row+=N*(x.row-w.row)}function v(I,w){var x=I.lines,N=I.end;I.end=a(w);var D=I.end.row-I.start.row,R=x.splice(D,x.length),S=D?w.column:w.column-I.start.column;x.push(R[0].substring(0,S)),R[0]=R[0].substr(S);var F={start:a(w),end:N,lines:R,action:I.action};return F}function M(I,w){w=r(w);for(var x=I.length;x--;){for(var N=I[x],D=0;DM&&(w=v.end.row+1,v=d.getNextFoldLine(w,v),M=v?v.start.row:1/0),w>_){for(;this.$lines.getLength()>I+1;)this.$lines.pop();break}y=this.$lines.get(++I),y?y.row=w:(y=this.$lines.createCell(w,h,this.session,c),this.$lines.push(y)),this.$renderCell(y,h,v,w),w++}this._signal("afterRender"),this.$updateGutterWidth(h)},l.prototype.$updateGutterWidth=function(h){var d=this.session,g=d.gutterRenderer||this.$renderer,_=d.$firstLineNumber,v=this.$lines.last()?this.$lines.last().text:"";(this.$fixedWidth||d.$useWrapMode)&&(v=d.getLength()+_-1);var M=g?g.getWidth(d,v,h):v.toString().length*h.characterWidth,y=this.$padding||this.$computePadding();M+=y.left+y.right,M!==this.gutterWidth&&!isNaN(M)&&(this.gutterWidth=M,this.element.parentNode.style.width=this.element.style.width=Math.ceil(this.gutterWidth)+"px",this._signal("changeGutterWidth",M))},l.prototype.$updateCursorRow=function(){if(this.$highlightGutterLine){var h=this.session.selection.getCursor();this.$cursorRow!==h.row&&(this.$cursorRow=h.row)}},l.prototype.updateLineHighlight=function(){if(this.$highlightGutterLine){var h=this.session.selection.cursor.row;if(this.$cursorRow=h,!(this.$cursorCell&&this.$cursorCell.row==h)){this.$cursorCell&&(this.$cursorCell.element.className=this.$cursorCell.element.className.replace("ace_gutter-active-line ",""));var d=this.$lines.cells;this.$cursorCell=null;for(var g=0;g=this.$cursorRow){if(_.row>this.$cursorRow){var v=this.session.getFoldLine(this.$cursorRow);if(g>0&&v&&v.start.row==d[g-1].row)_=d[g-1];else break}_.element.className="ace_gutter-active-line "+_.element.className,this.$cursorCell=_;break}}}}},l.prototype.scrollLines=function(h){var d=this.config;if(this.config=h,this.$updateCursorRow(),this.$lines.pageChanged(d,h))return this.update(h);this.$lines.moveContainer(h);var g=Math.min(h.lastRow+h.gutterOffset,this.session.getLength()-1),_=this.oldLastRow;if(this.oldLastRow=g,!d||_0;v--)this.$lines.shift();if(_>g)for(var v=this.session.getFoldedRowCount(g+1,_);v>0;v--)this.$lines.pop();h.firstRow_&&this.$lines.push(this.$renderLines(h,_+1,g)),this.updateLineHighlight(),this._signal("afterRender"),this.$updateGutterWidth(h)},l.prototype.$renderLines=function(h,d,g){for(var _=[],v=d,M=this.session.getNextFoldLine(v),y=M?M.start.row:1/0;v>y&&(v=M.end.row+1,M=this.session.getNextFoldLine(v,M),y=M?M.start.row:1/0),!(v>g);){var I=this.$lines.createCell(v,h,this.session,c);this.$renderCell(I,h,M,v),_.push(I),v++}return _},l.prototype.$renderCell=function(h,d,g,_){var v=h.element,M=this.session,y=v.childNodes[0],I=v.childNodes[1],w=v.childNodes[2],x=w.firstChild,N=M.$firstLineNumber,D=M.$breakpoints,R=M.$decorations,S=M.gutterRenderer||this.$renderer,F=this.$showFoldWidgets&&M.foldWidgets,A=g?g.start.row:Number.MAX_VALUE,E=d.lineHeight+"px",O=this.$useSvgGutterIcons?"ace_gutter-cell_svg-icons ":"ace_gutter-cell ",k=this.$useSvgGutterIcons?"ace_icon_svg":"ace_icon",H=(S?S.getText(M,_):_+N).toString();if(this.$highlightGutterLine&&(_==this.$cursorRow||g&&_=A&&this.$cursorRow<=g.end.row)&&(O+="ace_gutter-active-line ",this.$cursorCell!=h&&(this.$cursorCell&&(this.$cursorCell.element.className=this.$cursorCell.element.className.replace("ace_gutter-active-line ","")),this.$cursorCell=h)),D[_]&&(O+=D[_]),R[_]&&(O+=R[_]),this.$annotations[_]&&_!==A&&(O+=this.$annotations[_].className),v.className!=O&&(v.className=O),F){var V=F[_];V==null&&(V=F[_]=M.getFoldWidget(_))}if(V){var O="ace_fold-widget ace_"+V;if(V=="start"&&_==A&&_g.right-d.right)return"foldWidgets"},l}();o.prototype.$fixedWidth=!1,o.prototype.$highlightGutterLine=!0,o.prototype.$renderer="",o.prototype.$showLineNumbers=!0,o.prototype.$showFoldWidgets=!0,P.implement(o.prototype,f);function c(l){var h=document.createTextNode("");l.appendChild(h);var d=B.createElement("span");l.appendChild(d);var g=B.createElement("span");l.appendChild(g);var _=B.createElement("span");return g.appendChild(_),l}p.Gutter=o}),ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"],function(s,p,m){var B=s("../range").Range,P=s("../lib/dom"),C=function(){function a(r){this.element=P.createElement("div"),this.element.className="ace_layer ace_marker-layer",r.appendChild(this.element)}return a.prototype.setPadding=function(r){this.$padding=r},a.prototype.setSession=function(r){this.session=r},a.prototype.setMarkers=function(r){this.markers=r},a.prototype.elt=function(r,o){var c=this.i!=-1&&this.element.childNodes[this.i];c?this.i++:(c=document.createElement("div"),this.element.appendChild(c),this.i=-1),c.style.cssText=o,c.className=r},a.prototype.update=function(r){if(r){this.config=r,this.i=0;var o;for(var c in this.markers){var l=this.markers[c];if(!l.range){l.update(o,this,this.session,r);continue}var h=l.range.clipRows(r.firstRow,r.lastRow);if(!h.isEmpty())if(h=h.toScreenRange(this.session),l.renderer){var d=this.$getTop(h.start.row,r),g=this.$padding+h.start.column*r.characterWidth;l.renderer(o,h,g,d,r)}else l.type=="fullLine"?this.drawFullLineMarker(o,h,l.clazz,r):l.type=="screenLine"?this.drawScreenLineMarker(o,h,l.clazz,r):h.isMultiLine()?l.type=="text"?this.drawTextMarker(o,h,l.clazz,r):this.drawMultiLineMarker(o,h,l.clazz,r):this.drawSingleLineMarker(o,h,l.clazz+" ace_start ace_br15",r)}if(this.i!=-1)for(;this.iI,v==_),l,v==_?0:1,h)},a.prototype.drawMultiLineMarker=function(r,o,c,l,h){var d=this.$padding,g=l.lineHeight,_=this.$getTop(o.start.row,l),v=d+o.start.column*l.characterWidth;if(h=h||"",this.session.$bidiHandler.isBidiRow(o.start.row)){var M=o.clone();M.end.row=M.start.row,M.end.column=this.session.getLine(M.start.row).length,this.drawBidiSingleLineMarker(r,M,c+" ace_br1 ace_start",l,null,h)}else this.elt(c+" ace_br1 ace_start","height:"+g+"px;right:0;top:"+_+"px;left:"+v+"px;"+(h||""));if(this.session.$bidiHandler.isBidiRow(o.end.row)){var M=o.clone();M.start.row=M.end.row,M.start.column=0,this.drawBidiSingleLineMarker(r,M,c+" ace_br12",l,null,h)}else{_=this.$getTop(o.end.row,l);var y=o.end.column*l.characterWidth;this.elt(c+" ace_br12","height:"+g+"px;width:"+y+"px;top:"+_+"px;left:"+d+"px;"+(h||""))}if(g=(o.end.row-o.start.row-1)*l.lineHeight,!(g<=0)){_=this.$getTop(o.start.row+1,l);var I=(o.start.column?1:0)|(o.end.column?0:8);this.elt(c+(I?" ace_br"+I:""),"height:"+g+"px;right:0;top:"+_+"px;left:"+d+"px;"+(h||""))}},a.prototype.drawSingleLineMarker=function(r,o,c,l,h,d){if(this.session.$bidiHandler.isBidiRow(o.start.row))return this.drawBidiSingleLineMarker(r,o,c,l,h,d);var g=l.lineHeight,_=(o.end.column+(h||0)-o.start.column)*l.characterWidth,v=this.$getTop(o.start.row,l),M=this.$padding+o.start.column*l.characterWidth;this.elt(c,"height:"+g+"px;width:"+_+"px;top:"+v+"px;left:"+M+"px;"+(d||""))},a.prototype.drawBidiSingleLineMarker=function(r,o,c,l,h,d){var g=l.lineHeight,_=this.$getTop(o.start.row,l),v=this.$padding,M=this.session.$bidiHandler.getSelections(o.start.column,o.end.column);M.forEach(function(y){this.elt(c,"height:"+g+"px;width:"+(y.width+(h||0))+"px;top:"+_+"px;left:"+(v+y.left)+"px;"+(d||""))},this)},a.prototype.drawFullLineMarker=function(r,o,c,l,h){var d=this.$getTop(o.start.row,l),g=l.lineHeight;o.start.row!=o.end.row&&(g+=this.$getTop(o.end.row,l)-d),this.elt(c,"height:"+g+"px;top:"+d+"px;left:0;right:0;"+(h||""))},a.prototype.drawScreenLineMarker=function(r,o,c,l,h){var d=this.$getTop(o.start.row,l),g=l.lineHeight;this.elt(c,"height:"+g+"px;top:"+d+"px;left:0;right:0;"+(h||""))},a}();C.prototype.$padding=0;function f(a,r,o,c){return(a?1:0)|(r?2:0)|(o?4:0)|(c?8:0)}p.Marker=C}),ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/layer/lines","ace/lib/event_emitter","ace/config"],function(s,p,m){var B=s("../lib/oop"),P=s("../lib/dom"),C=s("../lib/lang"),f=s("./lines").Lines,a=s("../lib/event_emitter").EventEmitter,r=s("../config").nls,o=function(){function c(l){this.dom=P,this.element=this.dom.createElement("div"),this.element.className="ace_layer ace_text-layer",l.appendChild(this.element),this.$updateEolChar=this.$updateEolChar.bind(this),this.$lines=new f(this.element)}return c.prototype.$updateEolChar=function(){var l=this.session.doc,h=l.getNewLineCharacter()==` +`&&l.getNewLineMode()!="windows",d=h?this.EOL_CHAR_LF:this.EOL_CHAR_CRLF;if(this.EOL_CHAR!=d)return this.EOL_CHAR=d,!0},c.prototype.setPadding=function(l){this.$padding=l,this.element.style.margin="0 "+l+"px"},c.prototype.getLineHeight=function(){return this.$fontMetrics.$characterSize.height||0},c.prototype.getCharacterWidth=function(){return this.$fontMetrics.$characterSize.width||0},c.prototype.$setFontMetrics=function(l){this.$fontMetrics=l,this.$fontMetrics.on("changeCharacterSize",function(h){this._signal("changeCharacterSize",h)}.bind(this)),this.$pollSizeChanges()},c.prototype.checkForSizeChanges=function(){this.$fontMetrics.checkForSizeChanges()},c.prototype.$pollSizeChanges=function(){return this.$pollSizeChangesTimer=this.$fontMetrics.$pollSizeChanges()},c.prototype.setSession=function(l){this.session=l,l&&this.$computeTabString()},c.prototype.setShowInvisibles=function(l){return this.showInvisibles==l?!1:(this.showInvisibles=l,typeof l=="string"?(this.showSpaces=/tab/i.test(l),this.showTabs=/space/i.test(l),this.showEOL=/eol/i.test(l)):this.showSpaces=this.showTabs=this.showEOL=l,this.$computeTabString(),!0)},c.prototype.setDisplayIndentGuides=function(l){return this.displayIndentGuides==l?!1:(this.displayIndentGuides=l,this.$computeTabString(),!0)},c.prototype.setHighlightIndentGuides=function(l){return this.$highlightIndentGuides===l?!1:(this.$highlightIndentGuides=l,l)},c.prototype.$computeTabString=function(){var l=this.session.getTabSize();this.tabSize=l;for(var h=this.$tabStrings=[0],d=1;dx&&(I=w.end.row+1,w=this.session.getNextFoldLine(I,w),x=w?w.start.row:1/0),!(I>_);){var N=v[M++];if(N){this.dom.removeChildren(N),this.$renderLine(N,I,I==x?w:!1),y&&(N.style.top=this.$lines.computeLineTop(I,l,this.session)+"px");var D=l.lineHeight*this.session.getRowLength(I)+"px";N.style.height!=D&&(y=!0,N.style.height=D)}I++}if(y)for(;M0;_--)this.$lines.shift();if(h.lastRow>l.lastRow)for(var _=this.session.getFoldedRowCount(l.lastRow+1,h.lastRow);_>0;_--)this.$lines.pop();l.firstRowh.lastRow&&this.$lines.push(this.$renderLinesFragment(l,h.lastRow+1,l.lastRow)),this.$highlightIndentGuide()},c.prototype.$renderLinesFragment=function(l,h,d){for(var g=[],_=h,v=this.session.getNextFoldLine(_),M=v?v.start.row:1/0;_>M&&(_=v.end.row+1,v=this.session.getNextFoldLine(_,v),M=v?v.start.row:1/0),!(_>d);){var y=this.$lines.createCell(_,l,this.session),I=y.element;this.dom.removeChildren(I),P.setStyle(I.style,"height",this.$lines.computeLineHeight(_,l,this.session)+"px"),P.setStyle(I.style,"top",this.$lines.computeLineTop(_,l,this.session)+"px"),this.$renderLine(I,_,_==M?v:!1),this.$useLineGroups()?I.className="ace_line_group":I.className="ace_line",g.push(y),_++}return g},c.prototype.update=function(l){this.$lines.moveContainer(l),this.config=l;for(var h=l.firstRow,d=l.lastRow,g=this.$lines;g.getLength();)g.pop();g.push(this.$renderLinesFragment(l,h,d))},c.prototype.$renderToken=function(l,h,d,g){for(var _=this,v=/(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC\u2066\u2067\u2068\u202A\u202B\u202D\u202E\u202C\u2069]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g,M=this.dom.createFragment(this.element),y,I=0;y=v.exec(g);){var w=y[1],x=y[2],N=y[3],D=y[4],R=y[5];if(!(!_.showSpaces&&x)){var S=I!=y.index?g.slice(I,y.index):"";if(I=y.index+y[0].length,S&&M.appendChild(this.dom.createTextNode(S,this.element)),w){var F=_.session.getScreenTabSize(h+y.index);M.appendChild(_.$tabStrings[F].cloneNode(!0)),h+=F-1}else if(x)if(_.showSpaces){var A=this.dom.createElement("span");A.className="ace_invisible ace_invisible_space",A.textContent=C.stringRepeat(_.SPACE_CHAR,x.length),M.appendChild(A)}else M.appendChild(this.com.createTextNode(x,this.element));else if(N){var A=this.dom.createElement("span");A.className="ace_invisible ace_invisible_space ace_invalid",A.textContent=C.stringRepeat(_.SPACE_CHAR,N.length),M.appendChild(A)}else if(D){h+=1;var A=this.dom.createElement("span");A.style.width=_.config.characterWidth*2+"px",A.className=_.showSpaces?"ace_cjk ace_invisible ace_invisible_space":"ace_cjk",A.textContent=_.showSpaces?_.SPACE_CHAR:D,M.appendChild(A)}else if(R){h+=1;var A=this.dom.createElement("span");A.style.width=_.config.characterWidth*2+"px",A.className="ace_cjk",A.textContent=R,M.appendChild(A)}}}if(M.appendChild(this.dom.createTextNode(I?g.slice(I):g,this.element)),this.$textToken[d.type])l.appendChild(M);else{var E="ace_"+d.type.replace(/\./g," ace_"),A=this.dom.createElement("span");d.type=="fold"&&(A.style.width=d.value.length*this.config.characterWidth+"px",A.setAttribute("title",r("Unfold code"))),A.className=E,A.appendChild(M),l.appendChild(A)}return h+g.length},c.prototype.renderIndentGuide=function(l,h,d){var g=h.search(this.$indentGuideRe);if(g<=0||g>=d)return h;if(h[0]==" "){g-=g%this.tabSize;for(var _=g/this.tabSize,v=0;v<_;v++)l.appendChild(this.$tabStrings[" "].cloneNode(!0));return this.$highlightIndentGuide(),h.substr(g)}else if(h[0]==" "){for(var v=0;vv[M].start.row?this.$highlightIndentGuideMarker.dir=-1:this.$highlightIndentGuideMarker.dir=1;break}}if(!this.$highlightIndentGuideMarker.end&&l[h.row]!==""&&h.column===l[h.row].length){this.$highlightIndentGuideMarker.dir=1;for(var M=h.row+1;M0){for(var _=0;_=this.$highlightIndentGuideMarker.start+1){if(g.row>=this.$highlightIndentGuideMarker.end)break;this.$setIndentGuideActive(g,h)}}else for(var d=l.length-1;d>=0;d--){var g=l[d];if(this.$highlightIndentGuideMarker.end&&g.row=v;)M=this.$renderToken(y,M,w,x.substring(0,v-g)),x=x.substring(v-g),g=v,y=this.$createLineElement(),l.appendChild(y),y.appendChild(this.dom.createTextNode(C.stringRepeat(" ",d.indent),this.element)),_++,M=0,v=d[_]||Number.MAX_VALUE;x.length!=0&&(g+=x.length,M=this.$renderToken(y,M,w,x))}}d[d.length-1]>this.MAX_LINE_LENGTH&&this.$renderOverflowMessage(y,M,null,"",!0)},c.prototype.$renderSimpleLine=function(l,h){for(var d=0,g=0;gthis.MAX_LINE_LENGTH)return this.$renderOverflowMessage(l,d,_,v);d=this.$renderToken(l,d,_,v)}}},c.prototype.$renderOverflowMessage=function(l,h,d,g,_){d&&this.$renderToken(l,h,d,g.slice(0,this.MAX_LINE_LENGTH-h));var v=this.dom.createElement("span");v.className="ace_inline_button ace_keyword ace_toggle_wrap",v.textContent=_?"":"",l.appendChild(v)},c.prototype.$renderLine=function(l,h,d){if(!d&&d!=!1&&(d=this.session.getFoldLine(h)),d)var g=this.$getFoldLineTokens(h,d);else var g=this.session.getTokens(h);var _=l;if(g.length){var v=this.session.getRowSplitData(h);if(v&&v.length){this.$renderWrappedLine(l,g,v);var _=l.lastChild}else{var _=l;this.$useLineGroups()&&(_=this.$createLineElement(),l.appendChild(_)),this.$renderSimpleLine(_,g)}}else this.$useLineGroups()&&(_=this.$createLineElement(),l.appendChild(_));if(this.showEOL&&_){d&&(h=d.end.row);var M=this.dom.createElement("span");M.className="ace_invisible ace_invisible_eol",M.textContent=h==this.session.getLength()-1?this.EOF_CHAR:this.EOL_CHAR,_.appendChild(M)}},c.prototype.$getFoldLineTokens=function(l,h){var d=this.session,g=[];function _(M,y,I){for(var w=0,x=0;x+M[w].value.lengthI-y&&(N=N.substring(0,I-y)),g.push({type:M[w].type,value:N}),x=y+N.length,w+=1}for(;xI?g.push({type:M[w].type,value:N.substring(0,I-x)}):g.push(M[w]),x+=N.length,w+=1}}var v=d.getTokens(l);return h.walk(function(M,y,I,w,x){M!=null?g.push({type:"fold",value:M}):(x&&(v=d.getTokens(y)),v.length&&_(v,w,I))},h.end.row,this.session.getLine(h.end.row).length),g},c.prototype.$useLineGroups=function(){return this.session.getUseWrapMode()},c}();o.prototype.$textToken={text:!0,rparen:!0,lparen:!0},o.prototype.EOF_CHAR="¶",o.prototype.EOL_CHAR_LF="¬",o.prototype.EOL_CHAR_CRLF="¤",o.prototype.EOL_CHAR=o.prototype.EOL_CHAR_LF,o.prototype.TAB_CHAR="—",o.prototype.SPACE_CHAR="·",o.prototype.$padding=0,o.prototype.MAX_LINE_LENGTH=1e4,o.prototype.showInvisibles=!1,o.prototype.showSpaces=!1,o.prototype.showTabs=!1,o.prototype.showEOL=!1,o.prototype.displayIndentGuides=!0,o.prototype.$highlightIndentGuides=!0,o.prototype.$tabStrings=[],o.prototype.destroy={},o.prototype.onChangeTabSize=o.prototype.$computeTabString,B.implement(o.prototype,a),p.Text=o}),ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"],function(s,p,m){var B=s("../lib/dom"),P=function(){function C(f){this.element=B.createElement("div"),this.element.className="ace_layer ace_cursor-layer",f.appendChild(this.element),this.isVisible=!1,this.isBlinking=!0,this.blinkInterval=1e3,this.smoothBlinking=!1,this.cursors=[],this.cursor=this.addCursor(),B.addCssClass(this.element,"ace_hidden-cursors"),this.$updateCursors=this.$updateOpacity.bind(this)}return C.prototype.$updateOpacity=function(f){for(var a=this.cursors,r=a.length;r--;)B.setStyle(a[r].style,"opacity",f?"":"0")},C.prototype.$startCssAnimation=function(){for(var f=this.cursors,a=f.length;a--;)f[a].style.animationDuration=this.blinkInterval+"ms";this.$isAnimating=!0,setTimeout(function(){this.$isAnimating&&B.addCssClass(this.element,"ace_animate-blinking")}.bind(this))},C.prototype.$stopCssAnimation=function(){this.$isAnimating=!1,B.removeCssClass(this.element,"ace_animate-blinking")},C.prototype.setPadding=function(f){this.$padding=f},C.prototype.setSession=function(f){this.session=f},C.prototype.setBlinking=function(f){f!=this.isBlinking&&(this.isBlinking=f,this.restartTimer())},C.prototype.setBlinkInterval=function(f){f!=this.blinkInterval&&(this.blinkInterval=f,this.restartTimer())},C.prototype.setSmoothBlinking=function(f){f!=this.smoothBlinking&&(this.smoothBlinking=f,B.setCssClass(this.element,"ace_smooth-blinking",f),this.$updateCursors(!0),this.restartTimer())},C.prototype.addCursor=function(){var f=B.createElement("div");return f.className="ace_cursor",this.element.appendChild(f),this.cursors.push(f),f},C.prototype.removeCursor=function(){if(this.cursors.length>1){var f=this.cursors.pop();return f.parentNode.removeChild(f),f}},C.prototype.hideCursor=function(){this.isVisible=!1,B.addCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},C.prototype.showCursor=function(){this.isVisible=!0,B.removeCssClass(this.element,"ace_hidden-cursors"),this.restartTimer()},C.prototype.restartTimer=function(){var f=this.$updateCursors;if(clearInterval(this.intervalId),clearTimeout(this.timeoutId),this.$stopCssAnimation(),this.smoothBlinking&&(this.$isSmoothBlinking=!1,B.removeCssClass(this.element,"ace_smooth-blinking")),f(!0),!this.isBlinking||!this.blinkInterval||!this.isVisible){this.$stopCssAnimation();return}if(this.smoothBlinking&&(this.$isSmoothBlinking=!0,setTimeout(function(){this.$isSmoothBlinking&&B.addCssClass(this.element,"ace_smooth-blinking")}.bind(this))),B.HAS_CSS_ANIMATION)this.$startCssAnimation();else{var a=function(){this.timeoutId=setTimeout(function(){f(!1)},.6*this.blinkInterval)}.bind(this);this.intervalId=setInterval(function(){f(!0),a()},this.blinkInterval),a()}},C.prototype.getPixelPosition=function(f,a){if(!this.config||!this.session)return{left:0,top:0};f||(f=this.session.selection.getCursor());var r=this.session.documentToScreenPosition(f),o=this.$padding+(this.session.$bidiHandler.isBidiRow(r.row,f.row)?this.session.$bidiHandler.getPosLeft(r.column):r.column*this.config.characterWidth),c=(r.row-(a?this.config.firstRowScreen:0))*this.config.lineHeight;return{left:o,top:c}},C.prototype.isCursorInView=function(f,a){return f.top>=0&&f.topf.height+f.offset||l.top<0)&&r>1)){var h=this.cursors[o++]||this.addCursor(),d=h.style;this.drawCursor?this.drawCursor(h,l,f,a[r],this.session):this.isCursorInView(l,f)?(B.setStyle(d,"display","block"),B.translate(h,l.left,l.top),B.setStyle(d,"width",Math.round(f.characterWidth)+"px"),B.setStyle(d,"height",f.lineHeight+"px")):B.setStyle(d,"display","none")}}for(;this.cursors.length>o;)this.removeCursor();var g=this.session.getOverwrite();this.$setOverwrite(g),this.$pixelPos=l,this.restartTimer()},C.prototype.$setOverwrite=function(f){f!=this.overwrite&&(this.overwrite=f,f?B.addCssClass(this.element,"ace_overwrite-cursors"):B.removeCssClass(this.element,"ace_overwrite-cursors"))},C.prototype.destroy=function(){clearInterval(this.intervalId),clearTimeout(this.timeoutId)},C}();P.prototype.$padding=0,P.prototype.drawCursor=null,p.Cursor=P}),ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(s,p,m){var B=this&&this.__extends||function(){var h=function(d,g){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(_,v){_.__proto__=v}||function(_,v){for(var M in v)Object.prototype.hasOwnProperty.call(v,M)&&(_[M]=v[M])},h(d,g)};return function(d,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");h(d,g);function _(){this.constructor=d}d.prototype=g===null?Object.create(g):(_.prototype=g.prototype,new _)}}(),P=s("./lib/oop"),C=s("./lib/dom"),f=s("./lib/event"),a=s("./lib/event_emitter").EventEmitter,r=32768,o=function(){function h(d,g){this.element=C.createElement("div"),this.element.className="ace_scrollbar ace_scrollbar"+g,this.inner=C.createElement("div"),this.inner.className="ace_scrollbar-inner",this.inner.textContent=" ",this.element.appendChild(this.inner),d.appendChild(this.element),this.setVisible(!1),this.skipEvent=!1,f.addListener(this.element,"scroll",this.onScroll.bind(this)),f.addListener(this.element,"mousedown",f.preventDefault)}return h.prototype.setVisible=function(d){this.element.style.display=d?"":"none",this.isVisible=d,this.coeff=1},h}();P.implement(o.prototype,a);var c=function(h){B(d,h);function d(g,_){var v=h.call(this,g,"-v")||this;return v.scrollTop=0,v.scrollHeight=0,_.$scrollbarWidth=v.width=C.scrollbarWidth(g.ownerDocument),v.inner.style.width=v.element.style.width=(v.width||15)+5+"px",v.$minWidth=0,v}return d.prototype.onScroll=function(){if(!this.skipEvent){if(this.scrollTop=this.element.scrollTop,this.coeff!=1){var g=this.element.clientHeight/this.scrollHeight;this.scrollTop=this.scrollTop*(1-g)/(this.coeff-g)}this._emit("scroll",{data:this.scrollTop})}this.skipEvent=!1},d.prototype.getWidth=function(){return Math.max(this.isVisible?this.width:0,this.$minWidth||0)},d.prototype.setHeight=function(g){this.element.style.height=g+"px"},d.prototype.setScrollHeight=function(g){this.scrollHeight=g,g>r?(this.coeff=r/g,g=r):this.coeff!=1&&(this.coeff=1),this.inner.style.height=g+"px"},d.prototype.setScrollTop=function(g){this.scrollTop!=g&&(this.skipEvent=!0,this.scrollTop=g,this.element.scrollTop=g*this.coeff)},d}(o);c.prototype.setInnerHeight=c.prototype.setScrollHeight;var l=function(h){B(d,h);function d(g,_){var v=h.call(this,g,"-h")||this;return v.scrollLeft=0,v.height=_.$scrollbarWidth,v.inner.style.height=v.element.style.height=(v.height||15)+5+"px",v}return d.prototype.onScroll=function(){this.skipEvent||(this.scrollLeft=this.element.scrollLeft,this._emit("scroll",{data:this.scrollLeft})),this.skipEvent=!1},d.prototype.getHeight=function(){return this.isVisible?this.height:0},d.prototype.setWidth=function(g){this.element.style.width=g+"px"},d.prototype.setInnerWidth=function(g){this.inner.style.width=g+"px"},d.prototype.setScrollWidth=function(g){this.inner.style.width=g+"px"},d.prototype.setScrollLeft=function(g){this.scrollLeft!=g&&(this.skipEvent=!0,this.scrollLeft=this.element.scrollLeft=g)},d}(o);p.ScrollBar=c,p.ScrollBarV=c,p.ScrollBarH=l,p.VScrollBar=c,p.HScrollBar=l}),ace.define("ace/scrollbar_custom",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"],function(s,p,m){var B=this&&this.__extends||function(){var l=function(h,d){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,_){g.__proto__=_}||function(g,_){for(var v in _)Object.prototype.hasOwnProperty.call(_,v)&&(g[v]=_[v])},l(h,d)};return function(h,d){if(typeof d!="function"&&d!==null)throw new TypeError("Class extends value "+String(d)+" is not a constructor or null");l(h,d);function g(){this.constructor=h}h.prototype=d===null?Object.create(d):(g.prototype=d.prototype,new g)}}(),P=s("./lib/oop"),C=s("./lib/dom"),f=s("./lib/event"),a=s("./lib/event_emitter").EventEmitter;C.importCssString(`.ace_editor>.ace_sb-v div, .ace_editor>.ace_sb-h div{ position: absolute; background: rgba(128, 128, 128, 0.6); -moz-box-sizing: border-box; @@ -1329,7 +1329,7 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, r .ace_editor>.ace_sb_grabbed { z-index: 8; background: #000; -}`,"ace_scrollbar.css",!1);var s=function(){function l(h,d){this.element=C.createElement("div"),this.element.className="ace_sb"+d,this.inner=C.createElement("div"),this.inner.className="",this.element.appendChild(this.inner),this.VScrollWidth=12,this.HScrollHeight=12,h.appendChild(this.element),this.setVisible(!1),this.skipEvent=!1,f.addMultiMouseDownListener(this.element,[500,300,300],this,"onMouseDown")}return l.prototype.setVisible=function(h){this.element.style.display=h?"":"none",this.isVisible=h,this.coeff=1},l}();P.implement(s.prototype,a);var o=function(l){B(h,l);function h(d,g){var _=l.call(this,d,"-v")||this;return _.scrollTop=0,_.scrollHeight=0,_.parent=d,_.width=_.VScrollWidth,_.renderer=g,_.inner.style.width=_.element.style.width=(_.width||15)+"px",_.$minWidth=0,_}return h.prototype.onMouseDown=function(d,g){if(d==="mousedown"&&!(f.getButton(g)!==0||g.detail===2)){if(g.target===this.inner){var _=this,v=g.clientY,k=function(R){v=R.clientY},I=function(){clearInterval(N)},S=g.clientY,b=this.thumbTop,x=function(){if(v!==void 0){var R=_.scrollTopFromThumbTop(b+v-S);R!==_.scrollTop&&_._emit("scroll",{data:R})}};f.capture(this.inner,k,I);var N=setInterval(x,20);return f.preventDefault(g)}var D=g.clientY-this.element.getBoundingClientRect().top-this.thumbHeight/2;return this._emit("scroll",{data:this.scrollTopFromThumbTop(D)}),f.preventDefault(g)}},h.prototype.getHeight=function(){return this.height},h.prototype.scrollTopFromThumbTop=function(d){var g=d*(this.pageHeight-this.viewHeight)/(this.slideHeight-this.thumbHeight);return g=g>>0,g<0?g=0:g>this.pageHeight-this.viewHeight&&(g=this.pageHeight-this.viewHeight),g},h.prototype.getWidth=function(){return Math.max(this.isVisible?this.width:0,this.$minWidth||0)},h.prototype.setHeight=function(d){this.height=Math.max(0,d),this.slideHeight=this.height,this.viewHeight=this.height,this.setScrollHeight(this.pageHeight,!0)},h.prototype.setScrollHeight=function(d,g){this.pageHeight===d&&!g||(this.pageHeight=d,this.thumbHeight=this.slideHeight*this.viewHeight/this.pageHeight,this.thumbHeight>this.slideHeight&&(this.thumbHeight=this.slideHeight),this.thumbHeight<15&&(this.thumbHeight=15),this.inner.style.height=this.thumbHeight+"px",this.scrollTop>this.pageHeight-this.viewHeight&&(this.scrollTop=this.pageHeight-this.viewHeight,this.scrollTop<0&&(this.scrollTop=0),this._emit("scroll",{data:this.scrollTop})))},h.prototype.setScrollTop=function(d){this.scrollTop=d,d<0&&(d=0),this.thumbTop=d*(this.slideHeight-this.thumbHeight)/(this.pageHeight-this.viewHeight),this.inner.style.top=this.thumbTop+"px"},h}(s);o.prototype.setInnerHeight=o.prototype.setScrollHeight;var c=function(l){B(h,l);function h(d,g){var _=l.call(this,d,"-h")||this;return _.scrollLeft=0,_.scrollWidth=0,_.height=_.HScrollHeight,_.inner.style.height=_.element.style.height=(_.height||12)+"px",_.renderer=g,_}return h.prototype.onMouseDown=function(d,g){if(d==="mousedown"&&!(f.getButton(g)!==0||g.detail===2)){if(g.target===this.inner){var _=this,v=g.clientX,k=function(R){v=R.clientX},I=function(){clearInterval(N)},S=g.clientX,b=this.thumbLeft,x=function(){if(v!==void 0){var R=_.scrollLeftFromThumbLeft(b+v-S);R!==_.scrollLeft&&_._emit("scroll",{data:R})}};f.capture(this.inner,k,I);var N=setInterval(x,20);return f.preventDefault(g)}var D=g.clientX-this.element.getBoundingClientRect().left-this.thumbWidth/2;return this._emit("scroll",{data:this.scrollLeftFromThumbLeft(D)}),f.preventDefault(g)}},h.prototype.getHeight=function(){return this.isVisible?this.height:0},h.prototype.scrollLeftFromThumbLeft=function(d){var g=d*(this.pageWidth-this.viewWidth)/(this.slideWidth-this.thumbWidth);return g=g>>0,g<0?g=0:g>this.pageWidth-this.viewWidth&&(g=this.pageWidth-this.viewWidth),g},h.prototype.setWidth=function(d){this.width=Math.max(0,d),this.element.style.width=this.width+"px",this.slideWidth=this.width,this.viewWidth=this.width,this.setScrollWidth(this.pageWidth,!0)},h.prototype.setScrollWidth=function(d,g){this.pageWidth===d&&!g||(this.pageWidth=d,this.thumbWidth=this.slideWidth*this.viewWidth/this.pageWidth,this.thumbWidth>this.slideWidth&&(this.thumbWidth=this.slideWidth),this.thumbWidth<15&&(this.thumbWidth=15),this.inner.style.width=this.thumbWidth+"px",this.scrollLeft>this.pageWidth-this.viewWidth&&(this.scrollLeft=this.pageWidth-this.viewWidth,this.scrollLeft<0&&(this.scrollLeft=0),this._emit("scroll",{data:this.scrollLeft})))},h.prototype.setScrollLeft=function(d){this.scrollLeft=d,d<0&&(d=0),this.thumbLeft=d*(this.slideWidth-this.thumbWidth)/(this.pageWidth-this.viewWidth),this.inner.style.left=this.thumbLeft+"px"},h}(s);c.prototype.setInnerWidth=c.prototype.setScrollWidth,p.ScrollBar=o,p.ScrollBarV=o,p.ScrollBarH=c,p.VScrollBar=o,p.HScrollBar=c}),ace.define("ace/renderloop",["require","exports","module","ace/lib/event"],function(r,p,m){var B=r("./lib/event"),P=function(){function C(f,a){this.onRender=f,this.pending=!1,this.changes=0,this.$recursionLimit=2,this.window=a||window;var s=this;this._flush=function(o){s.pending=!1;var c=s.changes;if(c&&(B.blockIdle(100),s.changes=0,s.onRender(c)),s.changes){if(s.$recursionLimit--<0)return;s.schedule()}else s.$recursionLimit=2}}return C.prototype.schedule=function(f){this.changes=this.changes|f,this.changes&&!this.pending&&(B.nextFrame(this._flush),this.pending=!0)},C.prototype.clear=function(f){var a=this.changes;return this.changes=0,a},C}();p.RenderLoop=P}),ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/lib/useragent","ace/lib/event_emitter"],function(r,p,m){var B=r("../lib/oop"),P=r("../lib/dom"),C=r("../lib/lang"),f=r("../lib/event"),a=r("../lib/useragent"),s=r("../lib/event_emitter").EventEmitter,o=512,c=typeof ResizeObserver=="function",l=200,h=function(){function d(g){this.el=P.createElement("div"),this.$setMeasureNodeStyles(this.el.style,!0),this.$main=P.createElement("div"),this.$setMeasureNodeStyles(this.$main.style),this.$measureNode=P.createElement("div"),this.$setMeasureNodeStyles(this.$measureNode.style),this.el.appendChild(this.$main),this.el.appendChild(this.$measureNode),g.appendChild(this.el),this.$measureNode.textContent=C.stringRepeat("X",o),this.$characterSize={width:0,height:0},c?this.$addObserver():this.checkForSizeChanges()}return d.prototype.$setMeasureNodeStyles=function(g,_){g.width=g.height="auto",g.left=g.top="0px",g.visibility="hidden",g.position="absolute",g.whiteSpace="pre",a.isIE<8?g["font-family"]="inherit":g.font="inherit",g.overflow=_?"hidden":"visible"},d.prototype.checkForSizeChanges=function(g){if(g===void 0&&(g=this.$measureSizes()),g&&(this.$characterSize.width!==g.width||this.$characterSize.height!==g.height)){this.$measureNode.style.fontWeight="bold";var _=this.$measureSizes();this.$measureNode.style.fontWeight="",this.$characterSize=g,this.charSizes=Object.create(null),this.allowBoldFonts=_&&_.width===g.width&&_.height===g.height,this._emit("changeCharacterSize",{data:g})}},d.prototype.$addObserver=function(){var g=this;this.$observer=new window.ResizeObserver(function(_){g.checkForSizeChanges()}),this.$observer.observe(this.$measureNode)},d.prototype.$pollSizeChanges=function(){if(this.$pollSizeChangesTimer||this.$observer)return this.$pollSizeChangesTimer;var g=this;return this.$pollSizeChangesTimer=f.onIdle(function _(){g.checkForSizeChanges(),f.onIdle(_,500)},500)},d.prototype.setPolling=function(g){g?this.$pollSizeChanges():this.$pollSizeChangesTimer&&(clearInterval(this.$pollSizeChangesTimer),this.$pollSizeChangesTimer=0)},d.prototype.$measureSizes=function(g){var _={height:(g||this.$measureNode).clientHeight,width:(g||this.$measureNode).clientWidth/o};return _.width===0||_.height===0?null:_},d.prototype.$measureCharWidth=function(g){this.$main.textContent=C.stringRepeat(g,o);var _=this.$main.getBoundingClientRect();return _.width/o},d.prototype.getCharacterWidth=function(g){var _=this.charSizes[g];return _===void 0&&(_=this.charSizes[g]=this.$measureCharWidth(g)/this.$characterSize.width),_},d.prototype.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.$observer&&this.$observer.disconnect(),this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)},d.prototype.$getZoom=function(g){return!g||!g.parentElement?1:(window.getComputedStyle(g).zoom||1)*this.$getZoom(g.parentElement)},d.prototype.$initTransformMeasureNodes=function(){var g=function(_,v){return["div",{style:"position: absolute;top:"+_+"px;left:"+v+"px;"}]};this.els=P.buildDom([g(0,0),g(l,0),g(0,l),g(l,l)],this.el)},d.prototype.transformCoordinates=function(g,_){if(g){var v=this.$getZoom(this.el);g=b(1/v,g)}function k(K,Q,ie){var J=K[1]*Q[0]-K[0]*Q[1];return[(-Q[1]*ie[0]+Q[0]*ie[1])/J,(+K[1]*ie[0]-K[0]*ie[1])/J]}function I(K,Q){return[K[0]-Q[0],K[1]-Q[1]]}function S(K,Q){return[K[0]+Q[0],K[1]+Q[1]]}function b(K,Q){return[K*Q[0],K*Q[1]]}this.els||this.$initTransformMeasureNodes();function x(K){var Q=K.getBoundingClientRect();return[Q.left,Q.top]}var N=x(this.els[0]),D=x(this.els[1]),R=x(this.els[2]),w=x(this.els[3]),F=k(I(w,D),I(w,R),I(S(D,R),S(w,N))),A=b(1+F[0],I(D,N)),T=b(1+F[1],I(R,N));if(_){var L=_,O=F[0]*L[0]/l+F[1]*L[1]/l+1,H=S(b(L[0],A),b(L[1],T));return S(b(1/O/l,H),N)}var V=I(g,N),W=k(I(A,b(F[0],V)),I(T,b(F[1],V)),V);return b(l,W)},d}();h.prototype.$characterSize={width:0,height:0},B.implement(h.prototype,s),p.FontMetrics=h}),ace.define("ace/css/editor.css",["require","exports","module"],function(r,p,m){m.exports=` +}`,"ace_scrollbar.css",!1);var r=function(){function l(h,d){this.element=C.createElement("div"),this.element.className="ace_sb"+d,this.inner=C.createElement("div"),this.inner.className="",this.element.appendChild(this.inner),this.VScrollWidth=12,this.HScrollHeight=12,h.appendChild(this.element),this.setVisible(!1),this.skipEvent=!1,f.addMultiMouseDownListener(this.element,[500,300,300],this,"onMouseDown")}return l.prototype.setVisible=function(h){this.element.style.display=h?"":"none",this.isVisible=h,this.coeff=1},l}();P.implement(r.prototype,a);var o=function(l){B(h,l);function h(d,g){var _=l.call(this,d,"-v")||this;return _.scrollTop=0,_.scrollHeight=0,_.parent=d,_.width=_.VScrollWidth,_.renderer=g,_.inner.style.width=_.element.style.width=(_.width||15)+"px",_.$minWidth=0,_}return h.prototype.onMouseDown=function(d,g){if(d==="mousedown"&&!(f.getButton(g)!==0||g.detail===2)){if(g.target===this.inner){var _=this,v=g.clientY,M=function(R){v=R.clientY},y=function(){clearInterval(N)},I=g.clientY,w=this.thumbTop,x=function(){if(v!==void 0){var R=_.scrollTopFromThumbTop(w+v-I);R!==_.scrollTop&&_._emit("scroll",{data:R})}};f.capture(this.inner,M,y);var N=setInterval(x,20);return f.preventDefault(g)}var D=g.clientY-this.element.getBoundingClientRect().top-this.thumbHeight/2;return this._emit("scroll",{data:this.scrollTopFromThumbTop(D)}),f.preventDefault(g)}},h.prototype.getHeight=function(){return this.height},h.prototype.scrollTopFromThumbTop=function(d){var g=d*(this.pageHeight-this.viewHeight)/(this.slideHeight-this.thumbHeight);return g=g>>0,g<0?g=0:g>this.pageHeight-this.viewHeight&&(g=this.pageHeight-this.viewHeight),g},h.prototype.getWidth=function(){return Math.max(this.isVisible?this.width:0,this.$minWidth||0)},h.prototype.setHeight=function(d){this.height=Math.max(0,d),this.slideHeight=this.height,this.viewHeight=this.height,this.setScrollHeight(this.pageHeight,!0)},h.prototype.setScrollHeight=function(d,g){this.pageHeight===d&&!g||(this.pageHeight=d,this.thumbHeight=this.slideHeight*this.viewHeight/this.pageHeight,this.thumbHeight>this.slideHeight&&(this.thumbHeight=this.slideHeight),this.thumbHeight<15&&(this.thumbHeight=15),this.inner.style.height=this.thumbHeight+"px",this.scrollTop>this.pageHeight-this.viewHeight&&(this.scrollTop=this.pageHeight-this.viewHeight,this.scrollTop<0&&(this.scrollTop=0),this._emit("scroll",{data:this.scrollTop})))},h.prototype.setScrollTop=function(d){this.scrollTop=d,d<0&&(d=0),this.thumbTop=d*(this.slideHeight-this.thumbHeight)/(this.pageHeight-this.viewHeight),this.inner.style.top=this.thumbTop+"px"},h}(r);o.prototype.setInnerHeight=o.prototype.setScrollHeight;var c=function(l){B(h,l);function h(d,g){var _=l.call(this,d,"-h")||this;return _.scrollLeft=0,_.scrollWidth=0,_.height=_.HScrollHeight,_.inner.style.height=_.element.style.height=(_.height||12)+"px",_.renderer=g,_}return h.prototype.onMouseDown=function(d,g){if(d==="mousedown"&&!(f.getButton(g)!==0||g.detail===2)){if(g.target===this.inner){var _=this,v=g.clientX,M=function(R){v=R.clientX},y=function(){clearInterval(N)},I=g.clientX,w=this.thumbLeft,x=function(){if(v!==void 0){var R=_.scrollLeftFromThumbLeft(w+v-I);R!==_.scrollLeft&&_._emit("scroll",{data:R})}};f.capture(this.inner,M,y);var N=setInterval(x,20);return f.preventDefault(g)}var D=g.clientX-this.element.getBoundingClientRect().left-this.thumbWidth/2;return this._emit("scroll",{data:this.scrollLeftFromThumbLeft(D)}),f.preventDefault(g)}},h.prototype.getHeight=function(){return this.isVisible?this.height:0},h.prototype.scrollLeftFromThumbLeft=function(d){var g=d*(this.pageWidth-this.viewWidth)/(this.slideWidth-this.thumbWidth);return g=g>>0,g<0?g=0:g>this.pageWidth-this.viewWidth&&(g=this.pageWidth-this.viewWidth),g},h.prototype.setWidth=function(d){this.width=Math.max(0,d),this.element.style.width=this.width+"px",this.slideWidth=this.width,this.viewWidth=this.width,this.setScrollWidth(this.pageWidth,!0)},h.prototype.setScrollWidth=function(d,g){this.pageWidth===d&&!g||(this.pageWidth=d,this.thumbWidth=this.slideWidth*this.viewWidth/this.pageWidth,this.thumbWidth>this.slideWidth&&(this.thumbWidth=this.slideWidth),this.thumbWidth<15&&(this.thumbWidth=15),this.inner.style.width=this.thumbWidth+"px",this.scrollLeft>this.pageWidth-this.viewWidth&&(this.scrollLeft=this.pageWidth-this.viewWidth,this.scrollLeft<0&&(this.scrollLeft=0),this._emit("scroll",{data:this.scrollLeft})))},h.prototype.setScrollLeft=function(d){this.scrollLeft=d,d<0&&(d=0),this.thumbLeft=d*(this.slideWidth-this.thumbWidth)/(this.pageWidth-this.viewWidth),this.inner.style.left=this.thumbLeft+"px"},h}(r);c.prototype.setInnerWidth=c.prototype.setScrollWidth,p.ScrollBar=o,p.ScrollBarV=o,p.ScrollBarH=c,p.VScrollBar=o,p.HScrollBar=c}),ace.define("ace/renderloop",["require","exports","module","ace/lib/event"],function(s,p,m){var B=s("./lib/event"),P=function(){function C(f,a){this.onRender=f,this.pending=!1,this.changes=0,this.$recursionLimit=2,this.window=a||window;var r=this;this._flush=function(o){r.pending=!1;var c=r.changes;if(c&&(B.blockIdle(100),r.changes=0,r.onRender(c)),r.changes){if(r.$recursionLimit--<0)return;r.schedule()}else r.$recursionLimit=2}}return C.prototype.schedule=function(f){this.changes=this.changes|f,this.changes&&!this.pending&&(B.nextFrame(this._flush),this.pending=!0)},C.prototype.clear=function(f){var a=this.changes;return this.changes=0,a},C}();p.RenderLoop=P}),ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/lib/useragent","ace/lib/event_emitter"],function(s,p,m){var B=s("../lib/oop"),P=s("../lib/dom"),C=s("../lib/lang"),f=s("../lib/event"),a=s("../lib/useragent"),r=s("../lib/event_emitter").EventEmitter,o=512,c=typeof ResizeObserver=="function",l=200,h=function(){function d(g){this.el=P.createElement("div"),this.$setMeasureNodeStyles(this.el.style,!0),this.$main=P.createElement("div"),this.$setMeasureNodeStyles(this.$main.style),this.$measureNode=P.createElement("div"),this.$setMeasureNodeStyles(this.$measureNode.style),this.el.appendChild(this.$main),this.el.appendChild(this.$measureNode),g.appendChild(this.el),this.$measureNode.textContent=C.stringRepeat("X",o),this.$characterSize={width:0,height:0},c?this.$addObserver():this.checkForSizeChanges()}return d.prototype.$setMeasureNodeStyles=function(g,_){g.width=g.height="auto",g.left=g.top="0px",g.visibility="hidden",g.position="absolute",g.whiteSpace="pre",a.isIE<8?g["font-family"]="inherit":g.font="inherit",g.overflow=_?"hidden":"visible"},d.prototype.checkForSizeChanges=function(g){if(g===void 0&&(g=this.$measureSizes()),g&&(this.$characterSize.width!==g.width||this.$characterSize.height!==g.height)){this.$measureNode.style.fontWeight="bold";var _=this.$measureSizes();this.$measureNode.style.fontWeight="",this.$characterSize=g,this.charSizes=Object.create(null),this.allowBoldFonts=_&&_.width===g.width&&_.height===g.height,this._emit("changeCharacterSize",{data:g})}},d.prototype.$addObserver=function(){var g=this;this.$observer=new window.ResizeObserver(function(_){g.checkForSizeChanges()}),this.$observer.observe(this.$measureNode)},d.prototype.$pollSizeChanges=function(){if(this.$pollSizeChangesTimer||this.$observer)return this.$pollSizeChangesTimer;var g=this;return this.$pollSizeChangesTimer=f.onIdle(function _(){g.checkForSizeChanges(),f.onIdle(_,500)},500)},d.prototype.setPolling=function(g){g?this.$pollSizeChanges():this.$pollSizeChangesTimer&&(clearInterval(this.$pollSizeChangesTimer),this.$pollSizeChangesTimer=0)},d.prototype.$measureSizes=function(g){var _={height:(g||this.$measureNode).clientHeight,width:(g||this.$measureNode).clientWidth/o};return _.width===0||_.height===0?null:_},d.prototype.$measureCharWidth=function(g){this.$main.textContent=C.stringRepeat(g,o);var _=this.$main.getBoundingClientRect();return _.width/o},d.prototype.getCharacterWidth=function(g){var _=this.charSizes[g];return _===void 0&&(_=this.charSizes[g]=this.$measureCharWidth(g)/this.$characterSize.width),_},d.prototype.destroy=function(){clearInterval(this.$pollSizeChangesTimer),this.$observer&&this.$observer.disconnect(),this.el&&this.el.parentNode&&this.el.parentNode.removeChild(this.el)},d.prototype.$getZoom=function(g){return!g||!g.parentElement?1:(window.getComputedStyle(g).zoom||1)*this.$getZoom(g.parentElement)},d.prototype.$initTransformMeasureNodes=function(){var g=function(_,v){return["div",{style:"position: absolute;top:"+_+"px;left:"+v+"px;"}]};this.els=P.buildDom([g(0,0),g(l,0),g(0,l),g(l,l)],this.el)},d.prototype.transformCoordinates=function(g,_){if(g){var v=this.$getZoom(this.el);g=w(1/v,g)}function M(K,Q,ie){var J=K[1]*Q[0]-K[0]*Q[1];return[(-Q[1]*ie[0]+Q[0]*ie[1])/J,(+K[1]*ie[0]-K[0]*ie[1])/J]}function y(K,Q){return[K[0]-Q[0],K[1]-Q[1]]}function I(K,Q){return[K[0]+Q[0],K[1]+Q[1]]}function w(K,Q){return[K*Q[0],K*Q[1]]}this.els||this.$initTransformMeasureNodes();function x(K){var Q=K.getBoundingClientRect();return[Q.left,Q.top]}var N=x(this.els[0]),D=x(this.els[1]),R=x(this.els[2]),S=x(this.els[3]),F=M(y(S,D),y(S,R),y(I(D,R),I(S,N))),A=w(1+F[0],y(D,N)),E=w(1+F[1],y(R,N));if(_){var O=_,k=F[0]*O[0]/l+F[1]*O[1]/l+1,H=I(w(O[0],A),w(O[1],E));return I(w(1/k/l,H),N)}var V=y(g,N),W=M(y(A,w(F[0],V)),y(E,w(F[1],V)),V);return w(l,W)},d}();h.prototype.$characterSize={width:0,height:0},B.implement(h.prototype,r),p.FontMetrics=h}),ace.define("ace/css/editor.css",["require","exports","module"],function(s,p,m){m.exports=` .ace_br1 {border-top-left-radius : 3px;} .ace_br2 {border-top-right-radius : 3px;} .ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;} @@ -1971,11 +1971,11 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, r opacity: 0.5; font-style: italic; white-space: pre; -}`}),ace.define("ace/layer/decorators",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter"],function(r,p,m){var B=r("../lib/dom"),P=r("../lib/oop"),C=r("../lib/event_emitter").EventEmitter,f=function(){function a(s,o){this.canvas=B.createElement("canvas"),this.renderer=o,this.pixelRatio=1,this.maxHeight=o.layerConfig.maxHeight,this.lineHeight=o.layerConfig.lineHeight,this.canvasHeight=s.parent.scrollHeight,this.heightRatio=this.canvasHeight/this.maxHeight,this.canvasWidth=s.width,this.minDecorationHeight=2*this.pixelRatio|0,this.halfMinDecorationHeight=this.minDecorationHeight/2|0,this.canvas.width=this.canvasWidth,this.canvas.height=this.canvasHeight,this.canvas.style.top="0px",this.canvas.style.right="0px",this.canvas.style.zIndex="7px",this.canvas.style.position="absolute",this.colors={},this.colors.dark={error:"rgba(255, 18, 18, 1)",warning:"rgba(18, 136, 18, 1)",info:"rgba(18, 18, 136, 1)"},this.colors.light={error:"rgb(255,51,51)",warning:"rgb(32,133,72)",info:"rgb(35,68,138)"},s.element.appendChild(this.canvas)}return a.prototype.$updateDecorators=function(s){var o=this.renderer.theme.isDark===!0?this.colors.dark:this.colors.light;if(s){this.maxHeight=s.maxHeight,this.lineHeight=s.lineHeight,this.canvasHeight=s.height;var c=(s.lastRow+1)*this.lineHeight;cF.priority?1:0}var d=this.renderer.session.$annotations;if(l.clearRect(0,0,this.canvas.width,this.canvas.height),d){var g={info:1,warning:2,error:3};d.forEach(function(w){w.priority=g[w.type]||null}),d=d.sort(h);for(var _=this.renderer.session.$foldData,v=0;vthis.canvasHeight&&(D=this.canvasHeight-this.halfMinDecorationHeight),b=Math.round(D-this.halfMinDecorationHeight),x=Math.round(D+this.halfMinDecorationHeight)}l.fillStyle=o[d[v].type]||null,l.fillRect(0,S,this.canvasWidth,x-b)}}var R=this.renderer.session.selection.getCursor();if(R){var I=this.compensateFoldRows(R.row,_),S=Math.round((R.row-I)*this.lineHeight*this.heightRatio);l.fillStyle="rgba(0, 0, 0, 0.5)",l.fillRect(0,S,this.canvasWidth,2)}},a.prototype.compensateFoldRows=function(s,o){var c=0;if(o&&o.length>0)for(var l=0;lo[l].start.row&&s=o[l].end.row&&(c+=o[l].end.row-o[l].start.row);return c},a}();P.implement(f.prototype,C),p.Decorator=f}),ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/config","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/scrollbar_custom","ace/scrollbar_custom","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter","ace/css/editor.css","ace/layer/decorators","ace/lib/useragent"],function(r,p,m){var B=r("./lib/oop"),P=r("./lib/dom"),C=r("./lib/lang"),f=r("./config"),a=r("./layer/gutter").Gutter,s=r("./layer/marker").Marker,o=r("./layer/text").Text,c=r("./layer/cursor").Cursor,l=r("./scrollbar").HScrollBar,h=r("./scrollbar").VScrollBar,d=r("./scrollbar_custom").HScrollBar,g=r("./scrollbar_custom").VScrollBar,_=r("./renderloop").RenderLoop,v=r("./layer/font_metrics").FontMetrics,k=r("./lib/event_emitter").EventEmitter,I=r("./css/editor.css"),S=r("./layer/decorators").Decorator,b=r("./lib/useragent");P.importCssString(I,"ace_editor.css",!1);var x=function(){function N(D,R){var w=this;this.container=D||P.createElement("div"),P.addCssClass(this.container,"ace_editor"),P.HI_DPI&&P.addCssClass(this.container,"ace_hidpi"),this.setTheme(R),f.get("useStrictCSP")==null&&f.set("useStrictCSP",!1),this.$gutter=P.createElement("div"),this.$gutter.className="ace_gutter",this.container.appendChild(this.$gutter),this.$gutter.setAttribute("aria-hidden",!0),this.scroller=P.createElement("div"),this.scroller.className="ace_scroller",this.container.appendChild(this.scroller),this.content=P.createElement("div"),this.content.className="ace_content",this.scroller.appendChild(this.content),this.$gutterLayer=new a(this.$gutter),this.$gutterLayer.on("changeGutterWidth",this.onGutterResize.bind(this)),this.$markerBack=new s(this.content);var F=this.$textLayer=new o(this.content);this.canvas=F.element,this.$markerFront=new s(this.content),this.$cursorLayer=new c(this.content),this.$horizScroll=!1,this.$vScroll=!1,this.scrollBar=this.scrollBarV=new h(this.container,this),this.scrollBarH=new l(this.container,this),this.scrollBarV.on("scroll",function(A){w.$scrollAnimation||w.session.setScrollTop(A.data-w.scrollMargin.top)}),this.scrollBarH.on("scroll",function(A){w.$scrollAnimation||w.session.setScrollLeft(A.data-w.scrollMargin.left)}),this.scrollTop=0,this.scrollLeft=0,this.cursorPos={row:0,column:0},this.$fontMetrics=new v(this.container),this.$textLayer.$setFontMetrics(this.$fontMetrics),this.$textLayer.on("changeCharacterSize",function(A){w.updateCharacterSize(),w.onResize(!0,w.gutterWidth,w.$size.width,w.$size.height),w._signal("changeCharacterSize",A)}),this.$size={width:0,height:0,scrollerHeight:0,scrollerWidth:0,$dirty:!0},this.layerConfig={width:1,padding:0,firstRow:0,firstRowScreen:0,lastRow:0,lineHeight:0,characterWidth:0,minHeight:1,maxHeight:1,offset:0,height:1,gutterOffset:1},this.scrollMargin={left:0,right:0,top:0,bottom:0,v:0,h:0},this.margin={left:0,right:0,top:0,bottom:0,v:0,h:0},this.$keepTextAreaAtCursor=!b.isIOS,this.$loop=new _(this.$renderChanges.bind(this),this.container.ownerDocument.defaultView),this.$loop.schedule(this.CHANGE_FULL),this.updateCharacterSize(),this.setPadding(4),this.$addResizeObserver(),f.resetOptions(this),f._signal("renderer",this)}return N.prototype.updateCharacterSize=function(){this.$textLayer.allowBoldFonts!=this.$allowBoldFonts&&(this.$allowBoldFonts=this.$textLayer.allowBoldFonts,this.setStyle("ace_nobold",!this.$allowBoldFonts)),this.layerConfig.characterWidth=this.characterWidth=this.$textLayer.getCharacterWidth(),this.layerConfig.lineHeight=this.lineHeight=this.$textLayer.getLineHeight(),this.$updatePrintMargin(),P.setStyle(this.scroller.style,"line-height",this.lineHeight+"px")},N.prototype.setSession=function(D){this.session&&this.session.doc.off("changeNewLineMode",this.onChangeNewLineMode),this.session=D,D&&this.scrollMargin.top&&D.getScrollTop()<=0&&D.setScrollTop(-this.scrollMargin.top),this.$cursorLayer.setSession(D),this.$markerBack.setSession(D),this.$markerFront.setSession(D),this.$gutterLayer.setSession(D),this.$textLayer.setSession(D),D&&(this.$loop.schedule(this.CHANGE_FULL),this.session.$setFontMetrics(this.$fontMetrics),this.scrollBarH.scrollLeft=this.scrollBarV.scrollTop=null,this.onChangeNewLineMode=this.onChangeNewLineMode.bind(this),this.onChangeNewLineMode(),this.session.doc.on("changeNewLineMode",this.onChangeNewLineMode))},N.prototype.updateLines=function(D,R,w){if(R===void 0&&(R=1/0),this.$changedLines?(this.$changedLines.firstRow>D&&(this.$changedLines.firstRow=D),this.$changedLines.lastRowthis.layerConfig.lastRow||this.$loop.schedule(this.CHANGE_LINES)},N.prototype.onChangeNewLineMode=function(){this.$loop.schedule(this.CHANGE_TEXT),this.$textLayer.$updateEolChar(),this.session.$bidiHandler.setEolChar(this.$textLayer.EOL_CHAR)},N.prototype.onChangeTabSize=function(){this.$loop.schedule(this.CHANGE_TEXT|this.CHANGE_MARKER),this.$textLayer.onChangeTabSize()},N.prototype.updateText=function(){this.$loop.schedule(this.CHANGE_TEXT)},N.prototype.updateFull=function(D){D?this.$renderChanges(this.CHANGE_FULL,!0):this.$loop.schedule(this.CHANGE_FULL)},N.prototype.updateFontSize=function(){this.$textLayer.checkForSizeChanges()},N.prototype.$updateSizeAsync=function(){this.$loop.pending?this.$size.$dirty=!0:this.onResize()},N.prototype.onResize=function(D,R,w,F){if(!(this.resizing>2)){this.resizing>0?this.resizing++:this.resizing=D?1:0;var A=this.container;F||(F=A.clientHeight||A.scrollHeight),w||(w=A.clientWidth||A.scrollWidth);var T=this.$updateCachedSize(D,R,w,F);if(this.$resizeTimer&&this.$resizeTimer.cancel(),!this.$size.scrollerHeight||!w&&!F)return this.resizing=0;D&&(this.$gutterLayer.$padding=null),D?this.$renderChanges(T|this.$changes,!0):this.$loop.schedule(T|this.$changes),this.resizing&&(this.resizing=0),this.scrollBarH.scrollLeft=this.scrollBarV.scrollTop=null,this.$customScrollbar&&this.$updateCustomScrollbar(!0)}},N.prototype.$updateCachedSize=function(D,R,w,F){F-=this.$extraHeight||0;var A=0,T=this.$size,L={width:T.width,height:T.height,scrollerHeight:T.scrollerHeight,scrollerWidth:T.scrollerWidth};if(F&&(D||T.height!=F)&&(T.height=F,A|=this.CHANGE_SIZE,T.scrollerHeight=T.height,this.$horizScroll&&(T.scrollerHeight-=this.scrollBarH.getHeight()),this.scrollBarV.setHeight(T.scrollerHeight),this.scrollBarV.element.style.bottom=this.scrollBarH.getHeight()+"px",A=A|this.CHANGE_SCROLL),w&&(D||T.width!=w)){A|=this.CHANGE_SIZE,T.width=w,R==null&&(R=this.$showGutter?this.$gutter.offsetWidth:0),this.gutterWidth=R,P.setStyle(this.scrollBarH.element.style,"left",R+"px"),P.setStyle(this.scroller.style,"left",R+this.margin.left+"px"),T.scrollerWidth=Math.max(0,w-R-this.scrollBarV.getWidth()-this.margin.h),P.setStyle(this.$gutter.style,"left",this.margin.left+"px");var O=this.scrollBarV.getWidth()+"px";P.setStyle(this.scrollBarH.element.style,"right",O),P.setStyle(this.scroller.style,"right",O),P.setStyle(this.scroller.style,"bottom",this.scrollBarH.getHeight()),this.scrollBarH.setWidth(T.scrollerWidth),(this.session&&this.session.getUseWrapMode()&&this.adjustWrapLimit()||D)&&(A|=this.CHANGE_FULL)}return T.$dirty=!w||!F,A&&this._signal("resize",L),A},N.prototype.onGutterResize=function(D){var R=this.$showGutter?D:0;R!=this.gutterWidth&&(this.$changes|=this.$updateCachedSize(!0,R,this.$size.width,this.$size.height)),this.session.getUseWrapMode()&&this.adjustWrapLimit()?this.$loop.schedule(this.CHANGE_FULL):this.$size.$dirty?this.$loop.schedule(this.CHANGE_FULL):this.$computeLayerConfig()},N.prototype.adjustWrapLimit=function(){var D=this.$size.scrollerWidth-this.$padding*2,R=Math.floor(D/this.characterWidth);return this.session.adjustWrapLimit(R,this.$showPrintMargin&&this.$printMarginColumn)},N.prototype.setAnimatedScroll=function(D){this.setOption("animatedScroll",D)},N.prototype.getAnimatedScroll=function(){return this.$animatedScroll},N.prototype.setShowInvisibles=function(D){this.setOption("showInvisibles",D),this.session.$bidiHandler.setShowInvisibles(D)},N.prototype.getShowInvisibles=function(){return this.getOption("showInvisibles")},N.prototype.getDisplayIndentGuide=function(){return this.getOption("displayIndentGuides")},N.prototype.setDisplayIndentGuides=function(D){this.setOption("displayIndentGuides",D)},N.prototype.getHighlightIndentGuides=function(){return this.getOption("highlightIndentGuides")},N.prototype.setHighlightIndentGuides=function(D){this.setOption("highlightIndentGuides",D)},N.prototype.setShowPrintMargin=function(D){this.setOption("showPrintMargin",D)},N.prototype.getShowPrintMargin=function(){return this.getOption("showPrintMargin")},N.prototype.setPrintMarginColumn=function(D){this.setOption("printMarginColumn",D)},N.prototype.getPrintMarginColumn=function(){return this.getOption("printMarginColumn")},N.prototype.getShowGutter=function(){return this.getOption("showGutter")},N.prototype.setShowGutter=function(D){return this.setOption("showGutter",D)},N.prototype.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},N.prototype.setFadeFoldWidgets=function(D){this.setOption("fadeFoldWidgets",D)},N.prototype.setHighlightGutterLine=function(D){this.setOption("highlightGutterLine",D)},N.prototype.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},N.prototype.$updatePrintMargin=function(){if(!(!this.$showPrintMargin&&!this.$printMarginEl)){if(!this.$printMarginEl){var D=P.createElement("div");D.className="ace_layer ace_print-margin-layer",this.$printMarginEl=P.createElement("div"),this.$printMarginEl.className="ace_print-margin",D.appendChild(this.$printMarginEl),this.content.insertBefore(D,this.content.firstChild)}var R=this.$printMarginEl.style;R.left=Math.round(this.characterWidth*this.$printMarginColumn+this.$padding)+"px",R.visibility=this.$showPrintMargin?"visible":"hidden",this.session&&this.session.$wrap==-1&&this.adjustWrapLimit()}},N.prototype.getContainerElement=function(){return this.container},N.prototype.getMouseEventTarget=function(){return this.scroller},N.prototype.getTextAreaContainer=function(){return this.container},N.prototype.$moveTextAreaToCursor=function(){if(!this.$isMousePressed){var D=this.textarea.style,R=this.$composition;if(!this.$keepTextAreaAtCursor&&!R){P.translate(this.textarea,-100,0);return}var w=this.$cursorLayer.$pixelPos;if(w){R&&R.markerRange&&(w=this.$cursorLayer.getPixelPosition(R.markerRange.start,!0));var F=this.layerConfig,A=w.top,T=w.left;A-=F.offset;var L=R&&R.useTextareaForIME||b.isMobile?this.lineHeight:1;if(A<0||A>F.height-L){P.translate(this.textarea,0,0);return}var O=1,H=this.$size.height-L;if(!R)A+=this.lineHeight;else if(R.useTextareaForIME){var V=this.textarea.value;O=this.characterWidth*this.session.$getStringScreenWidth(V)[0]}else A+=this.lineHeight+2;T-=this.scrollLeft,T>this.$size.scrollerWidth-O&&(T=this.$size.scrollerWidth-O),T+=this.gutterWidth+this.margin.left,P.setStyle(D,"height",L+"px"),P.setStyle(D,"width",O+"px"),P.translate(this.textarea,Math.min(T,this.$size.scrollerWidth-O),Math.min(A,H))}}},N.prototype.getFirstVisibleRow=function(){return this.layerConfig.firstRow},N.prototype.getFirstFullyVisibleRow=function(){return this.layerConfig.firstRow+(this.layerConfig.offset===0?0:1)},N.prototype.getLastFullyVisibleRow=function(){var D=this.layerConfig,R=D.lastRow,w=this.session.documentToScreenRow(R,0)*D.lineHeight;return w-this.session.getScrollTop()>D.height-D.lineHeight?R-1:R},N.prototype.getLastVisibleRow=function(){return this.layerConfig.lastRow},N.prototype.setPadding=function(D){this.$padding=D,this.$textLayer.setPadding(D),this.$cursorLayer.setPadding(D),this.$markerFront.setPadding(D),this.$markerBack.setPadding(D),this.$loop.schedule(this.CHANGE_FULL),this.$updatePrintMargin()},N.prototype.setScrollMargin=function(D,R,w,F){var A=this.scrollMargin;A.top=D|0,A.bottom=R|0,A.right=F|0,A.left=w|0,A.v=A.top+A.bottom,A.h=A.left+A.right,A.top&&this.scrollTop<=0&&this.session&&this.session.setScrollTop(-A.top),this.updateFull()},N.prototype.setMargin=function(D,R,w,F){var A=this.margin;A.top=D|0,A.bottom=R|0,A.right=F|0,A.left=w|0,A.v=A.top+A.bottom,A.h=A.left+A.right,this.$updateCachedSize(!0,this.gutterWidth,this.$size.width,this.$size.height),this.updateFull()},N.prototype.getHScrollBarAlwaysVisible=function(){return this.$hScrollBarAlwaysVisible},N.prototype.setHScrollBarAlwaysVisible=function(D){this.setOption("hScrollBarAlwaysVisible",D)},N.prototype.getVScrollBarAlwaysVisible=function(){return this.$vScrollBarAlwaysVisible},N.prototype.setVScrollBarAlwaysVisible=function(D){this.setOption("vScrollBarAlwaysVisible",D)},N.prototype.$updateScrollBarV=function(){var D=this.layerConfig.maxHeight,R=this.$size.scrollerHeight;!this.$maxLines&&this.$scrollPastEnd&&(D-=(R-this.lineHeight)*this.$scrollPastEnd,this.scrollTop>D-R&&(D=this.scrollTop+R,this.scrollBarV.scrollTop=null)),this.scrollBarV.setScrollHeight(D+this.scrollMargin.v),this.scrollBarV.setScrollTop(this.scrollTop+this.scrollMargin.top)},N.prototype.$updateScrollBarH=function(){this.scrollBarH.setScrollWidth(this.layerConfig.width+2*this.$padding+this.scrollMargin.h),this.scrollBarH.setScrollLeft(this.scrollLeft+this.scrollMargin.left)},N.prototype.freeze=function(){this.$frozen=!0},N.prototype.unfreeze=function(){this.$frozen=!1},N.prototype.$renderChanges=function(D,R){if(this.$changes&&(D|=this.$changes,this.$changes=0),!this.session||!this.container.offsetWidth||this.$frozen||!D&&!R){this.$changes|=D;return}if(this.$size.$dirty)return this.$changes|=D,this.onResize(!0);this.lineHeight||this.$textLayer.checkForSizeChanges(),this._signal("beforeRender",D),this.session&&this.session.$bidiHandler&&this.session.$bidiHandler.updateCharacterWidths(this.$fontMetrics);var w=this.layerConfig;if(D&this.CHANGE_FULL||D&this.CHANGE_SIZE||D&this.CHANGE_TEXT||D&this.CHANGE_LINES||D&this.CHANGE_SCROLL||D&this.CHANGE_H_SCROLL){if(D|=this.$computeLayerConfig()|this.$loop.clear(),w.firstRow!=this.layerConfig.firstRow&&w.firstRowScreen==this.layerConfig.firstRowScreen){var F=this.scrollTop+(w.firstRow-Math.max(this.layerConfig.firstRow,0))*this.lineHeight;F>0&&(this.scrollTop=F,D=D|this.CHANGE_SCROLL,D|=this.$computeLayerConfig()|this.$loop.clear())}w=this.layerConfig,this.$updateScrollBarV(),D&this.CHANGE_H_SCROLL&&this.$updateScrollBarH(),P.translate(this.content,-this.scrollLeft,-w.offset);var A=w.width+2*this.$padding+"px",T=w.minHeight+"px";P.setStyle(this.content.style,"width",A),P.setStyle(this.content.style,"height",T)}if(D&this.CHANGE_H_SCROLL&&(P.translate(this.content,-this.scrollLeft,-w.offset),this.scroller.className=this.scrollLeft<=0?"ace_scroller ":"ace_scroller ace_scroll-left ",this.enableKeyboardAccessibility&&(this.scroller.className+=this.keyboardFocusClassName)),D&this.CHANGE_FULL){this.$changedLines=null,this.$textLayer.update(w),this.$showGutter&&this.$gutterLayer.update(w),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(w),this.$markerBack.update(w),this.$markerFront.update(w),this.$cursorLayer.update(w),this.$moveTextAreaToCursor(),this._signal("afterRender",D);return}if(D&this.CHANGE_SCROLL){this.$changedLines=null,D&this.CHANGE_TEXT||D&this.CHANGE_LINES?this.$textLayer.update(w):this.$textLayer.scrollLines(w),this.$showGutter&&(D&this.CHANGE_GUTTER||D&this.CHANGE_LINES?this.$gutterLayer.update(w):this.$gutterLayer.scrollLines(w)),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(w),this.$markerBack.update(w),this.$markerFront.update(w),this.$cursorLayer.update(w),this.$moveTextAreaToCursor(),this._signal("afterRender",D);return}D&this.CHANGE_TEXT?(this.$changedLines=null,this.$textLayer.update(w),this.$showGutter&&this.$gutterLayer.update(w),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(w)):D&this.CHANGE_LINES?((this.$updateLines()||D&this.CHANGE_GUTTER&&this.$showGutter)&&this.$gutterLayer.update(w),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(w)):D&this.CHANGE_TEXT||D&this.CHANGE_GUTTER?(this.$showGutter&&this.$gutterLayer.update(w),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(w)):D&this.CHANGE_CURSOR&&(this.$highlightGutterLine&&this.$gutterLayer.updateLineHighlight(w),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(w)),D&this.CHANGE_CURSOR&&(this.$cursorLayer.update(w),this.$moveTextAreaToCursor()),D&(this.CHANGE_MARKER|this.CHANGE_MARKER_FRONT)&&this.$markerFront.update(w),D&(this.CHANGE_MARKER|this.CHANGE_MARKER_BACK)&&this.$markerBack.update(w),this._signal("afterRender",D)},N.prototype.$autosize=function(){var D=this.session.getScreenLength()*this.lineHeight,R=this.$maxLines*this.lineHeight,w=Math.min(R,Math.max((this.$minLines||1)*this.lineHeight,D))+this.scrollMargin.v+(this.$extraHeight||0);this.$horizScroll&&(w+=this.scrollBarH.getHeight()),this.$maxPixelHeight&&w>this.$maxPixelHeight&&(w=this.$maxPixelHeight);var F=w<=2*this.lineHeight,A=!F&&D>R;if(w!=this.desiredHeight||this.$size.height!=this.desiredHeight||A!=this.$vScroll){A!=this.$vScroll&&(this.$vScroll=A,this.scrollBarV.setVisible(A));var T=this.container.clientWidth;this.container.style.height=w+"px",this.$updateCachedSize(!0,this.$gutterWidth,T,w),this.desiredHeight=w,this._signal("autosize")}},N.prototype.$computeLayerConfig=function(){var D=this.session,R=this.$size,w=R.height<=2*this.lineHeight,F=this.session.getScreenLength(),A=F*this.lineHeight,T=this.$getLongestLine(),L=!w&&(this.$hScrollBarAlwaysVisible||R.scrollerWidth-T-2*this.$padding<0),O=this.$horizScroll!==L;O&&(this.$horizScroll=L,this.scrollBarH.setVisible(L));var H=this.$vScroll;this.$maxLines&&this.lineHeight>1&&this.$autosize();var V=R.scrollerHeight+this.lineHeight,W=!this.$maxLines&&this.$scrollPastEnd?(R.scrollerHeight-this.lineHeight)*this.$scrollPastEnd:0;A+=W;var K=this.scrollMargin;this.session.setScrollTop(Math.max(-K.top,Math.min(this.scrollTop,A-R.scrollerHeight+K.bottom))),this.session.setScrollLeft(Math.max(-K.left,Math.min(this.scrollLeft,T+2*this.$padding-R.scrollerWidth+K.right)));var Q=!w&&(this.$vScrollBarAlwaysVisible||R.scrollerHeight-A+W<0||this.scrollTop>K.top),ie=H!==Q;ie&&(this.$vScroll=Q,this.scrollBarV.setVisible(Q));var J=this.scrollTop%this.lineHeight,Y=Math.ceil(V/this.lineHeight)-1,z=Math.max(0,Math.round((this.scrollTop-J)/this.lineHeight)),oe=z+Y,he,de,fe=this.lineHeight;z=D.screenToDocumentRow(z,0);var le=D.getFoldLine(z);le&&(z=le.start.row),he=D.documentToScreenRow(z,0),de=D.getRowLength(z)*fe,oe=Math.min(D.screenToDocumentRow(oe,0),D.getLength()-1),V=R.scrollerHeight+D.getRowLength(oe)*fe+de,J=this.scrollTop-he*fe;var Re=0;return(this.layerConfig.width!=T||O)&&(Re=this.CHANGE_H_SCROLL),(O||ie)&&(Re|=this.$updateCachedSize(!0,this.gutterWidth,R.width,R.height),this._signal("scrollbarVisibilityChanged"),ie&&(T=this.$getLongestLine())),this.layerConfig={width:T,padding:this.$padding,firstRow:z,firstRowScreen:he,lastRow:oe,lineHeight:fe,characterWidth:this.characterWidth,minHeight:V,maxHeight:A,offset:J,gutterOffset:fe?Math.max(0,Math.ceil((J+R.height-R.scrollerHeight)/fe)):0,height:this.$size.scrollerHeight},this.session.$bidiHandler&&this.session.$bidiHandler.setContentWidth(T-this.$padding),Re},N.prototype.$updateLines=function(){if(this.$changedLines){var D=this.$changedLines.firstRow,R=this.$changedLines.lastRow;this.$changedLines=null;var w=this.layerConfig;if(!(D>w.lastRow+1)&&!(Rthis.$textLayer.MAX_LINE_LENGTH&&(D=this.$textLayer.MAX_LINE_LENGTH+30),Math.max(this.$size.scrollerWidth-2*this.$padding,Math.round(D*this.characterWidth))},N.prototype.updateFrontMarkers=function(){this.$markerFront.setMarkers(this.session.getMarkers(!0)),this.$loop.schedule(this.CHANGE_MARKER_FRONT)},N.prototype.updateBackMarkers=function(){this.$markerBack.setMarkers(this.session.getMarkers()),this.$loop.schedule(this.CHANGE_MARKER_BACK)},N.prototype.addGutterDecoration=function(D,R){this.$gutterLayer.addGutterDecoration(D,R)},N.prototype.removeGutterDecoration=function(D,R){this.$gutterLayer.removeGutterDecoration(D,R)},N.prototype.updateBreakpoints=function(D){this.$loop.schedule(this.CHANGE_GUTTER)},N.prototype.setAnnotations=function(D){this.$gutterLayer.setAnnotations(D),this.$loop.schedule(this.CHANGE_GUTTER)},N.prototype.updateCursor=function(){this.$loop.schedule(this.CHANGE_CURSOR)},N.prototype.hideCursor=function(){this.$cursorLayer.hideCursor()},N.prototype.showCursor=function(){this.$cursorLayer.showCursor()},N.prototype.scrollSelectionIntoView=function(D,R,w){this.scrollCursorIntoView(D,w),this.scrollCursorIntoView(R,w)},N.prototype.scrollCursorIntoView=function(D,R,w){if(this.$size.scrollerHeight!==0){var F=this.$cursorLayer.getPixelPosition(D),A=F.left,T=F.top,L=w&&w.top||0,O=w&&w.bottom||0;this.$scrollAnimation&&(this.$stopAnimation=!0);var H=this.$scrollAnimation?this.session.getScrollTop():this.scrollTop;H+L>T?(R&&H+L>T+this.lineHeight&&(T-=R*this.$size.scrollerHeight),T===0&&(T=-this.scrollMargin.top),this.session.setScrollTop(T)):H+this.$size.scrollerHeight-O=1-this.scrollMargin.top||R>0&&this.session.getScrollTop()+this.$size.scrollerHeight-this.layerConfig.maxHeight<-1+this.scrollMargin.bottom||D<0&&this.session.getScrollLeft()>=1-this.scrollMargin.left||D>0&&this.session.getScrollLeft()+this.$size.scrollerWidth-this.layerConfig.width<-1+this.scrollMargin.right)return!0},N.prototype.pixelToScreenCoordinates=function(D,R){var w;if(this.$hasCssTransforms){w={top:0,left:0};var F=this.$fontMetrics.transformCoordinates([D,R]);D=F[1]-this.gutterWidth-this.margin.left,R=F[0]}else w=this.scroller.getBoundingClientRect();var A=D+this.scrollLeft-w.left-this.$padding,T=A/this.characterWidth,L=Math.floor((R+this.scrollTop-w.top)/this.lineHeight),O=this.$blockCursor?Math.floor(T):Math.round(T);return{row:L,column:O,side:T-O>0?1:-1,offsetX:A}},N.prototype.screenToTextCoordinates=function(D,R){var w;if(this.$hasCssTransforms){w={top:0,left:0};var F=this.$fontMetrics.transformCoordinates([D,R]);D=F[1]-this.gutterWidth-this.margin.left,R=F[0]}else w=this.scroller.getBoundingClientRect();var A=D+this.scrollLeft-w.left-this.$padding,T=A/this.characterWidth,L=this.$blockCursor?Math.floor(T):Math.round(T),O=Math.floor((R+this.scrollTop-w.top)/this.lineHeight);return this.session.screenToDocumentPosition(O,Math.max(L,0),A)},N.prototype.textToScreenCoordinates=function(D,R){var w=this.scroller.getBoundingClientRect(),F=this.session.documentToScreenPosition(D,R),A=this.$padding+(this.session.$bidiHandler.isBidiRow(F.row,D)?this.session.$bidiHandler.getPosLeft(F.column):Math.round(F.column*this.characterWidth)),T=F.row*this.lineHeight;return{pageX:w.left+A-this.scrollLeft,pageY:w.top+T-this.scrollTop}},N.prototype.visualizeFocus=function(){P.addCssClass(this.container,"ace_focus")},N.prototype.visualizeBlur=function(){P.removeCssClass(this.container,"ace_focus")},N.prototype.showComposition=function(D){this.$composition=D,D.cssText||(D.cssText=this.textarea.style.cssText),D.useTextareaForIME==null&&(D.useTextareaForIME=this.$useTextareaForIME),this.$useTextareaForIME?(P.addCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText="",this.$moveTextAreaToCursor(),this.$cursorLayer.element.style.display="none"):D.markerId=this.session.addMarker(D.markerRange,"ace_composition_marker","text")},N.prototype.setCompositionText=function(D){var R=this.session.selection.cursor;this.addToken(D,"composition_placeholder",R.row,R.column),this.$moveTextAreaToCursor()},N.prototype.hideComposition=function(){if(this.$composition){this.$composition.markerId&&this.session.removeMarker(this.$composition.markerId),P.removeCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText=this.$composition.cssText;var D=this.session.selection.cursor;this.removeExtraToken(D.row,D.column),this.$composition=null,this.$cursorLayer.element.style.display=""}},N.prototype.setGhostText=function(D,R){var w=this.session.selection.cursor,F=R||{row:w.row,column:w.column};this.removeGhostText();var A=D.split(` +}`}),ace.define("ace/layer/decorators",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter"],function(s,p,m){var B=s("../lib/dom"),P=s("../lib/oop"),C=s("../lib/event_emitter").EventEmitter,f=function(){function a(r,o){this.canvas=B.createElement("canvas"),this.renderer=o,this.pixelRatio=1,this.maxHeight=o.layerConfig.maxHeight,this.lineHeight=o.layerConfig.lineHeight,this.canvasHeight=r.parent.scrollHeight,this.heightRatio=this.canvasHeight/this.maxHeight,this.canvasWidth=r.width,this.minDecorationHeight=2*this.pixelRatio|0,this.halfMinDecorationHeight=this.minDecorationHeight/2|0,this.canvas.width=this.canvasWidth,this.canvas.height=this.canvasHeight,this.canvas.style.top="0px",this.canvas.style.right="0px",this.canvas.style.zIndex="7px",this.canvas.style.position="absolute",this.colors={},this.colors.dark={error:"rgba(255, 18, 18, 1)",warning:"rgba(18, 136, 18, 1)",info:"rgba(18, 18, 136, 1)"},this.colors.light={error:"rgb(255,51,51)",warning:"rgb(32,133,72)",info:"rgb(35,68,138)"},r.element.appendChild(this.canvas)}return a.prototype.$updateDecorators=function(r){var o=this.renderer.theme.isDark===!0?this.colors.dark:this.colors.light;if(r){this.maxHeight=r.maxHeight,this.lineHeight=r.lineHeight,this.canvasHeight=r.height;var c=(r.lastRow+1)*this.lineHeight;cF.priority?1:0}var d=this.renderer.session.$annotations;if(l.clearRect(0,0,this.canvas.width,this.canvas.height),d){var g={info:1,warning:2,error:3};d.forEach(function(S){S.priority=g[S.type]||null}),d=d.sort(h);for(var _=this.renderer.session.$foldData,v=0;vthis.canvasHeight&&(D=this.canvasHeight-this.halfMinDecorationHeight),w=Math.round(D-this.halfMinDecorationHeight),x=Math.round(D+this.halfMinDecorationHeight)}l.fillStyle=o[d[v].type]||null,l.fillRect(0,I,this.canvasWidth,x-w)}}var R=this.renderer.session.selection.getCursor();if(R){var y=this.compensateFoldRows(R.row,_),I=Math.round((R.row-y)*this.lineHeight*this.heightRatio);l.fillStyle="rgba(0, 0, 0, 0.5)",l.fillRect(0,I,this.canvasWidth,2)}},a.prototype.compensateFoldRows=function(r,o){var c=0;if(o&&o.length>0)for(var l=0;lo[l].start.row&&r=o[l].end.row&&(c+=o[l].end.row-o[l].start.row);return c},a}();P.implement(f.prototype,C),p.Decorator=f}),ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/config","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/scrollbar_custom","ace/scrollbar_custom","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter","ace/css/editor.css","ace/layer/decorators","ace/lib/useragent"],function(s,p,m){var B=s("./lib/oop"),P=s("./lib/dom"),C=s("./lib/lang"),f=s("./config"),a=s("./layer/gutter").Gutter,r=s("./layer/marker").Marker,o=s("./layer/text").Text,c=s("./layer/cursor").Cursor,l=s("./scrollbar").HScrollBar,h=s("./scrollbar").VScrollBar,d=s("./scrollbar_custom").HScrollBar,g=s("./scrollbar_custom").VScrollBar,_=s("./renderloop").RenderLoop,v=s("./layer/font_metrics").FontMetrics,M=s("./lib/event_emitter").EventEmitter,y=s("./css/editor.css"),I=s("./layer/decorators").Decorator,w=s("./lib/useragent");P.importCssString(y,"ace_editor.css",!1);var x=function(){function N(D,R){var S=this;this.container=D||P.createElement("div"),P.addCssClass(this.container,"ace_editor"),P.HI_DPI&&P.addCssClass(this.container,"ace_hidpi"),this.setTheme(R),f.get("useStrictCSP")==null&&f.set("useStrictCSP",!1),this.$gutter=P.createElement("div"),this.$gutter.className="ace_gutter",this.container.appendChild(this.$gutter),this.$gutter.setAttribute("aria-hidden",!0),this.scroller=P.createElement("div"),this.scroller.className="ace_scroller",this.container.appendChild(this.scroller),this.content=P.createElement("div"),this.content.className="ace_content",this.scroller.appendChild(this.content),this.$gutterLayer=new a(this.$gutter),this.$gutterLayer.on("changeGutterWidth",this.onGutterResize.bind(this)),this.$markerBack=new r(this.content);var F=this.$textLayer=new o(this.content);this.canvas=F.element,this.$markerFront=new r(this.content),this.$cursorLayer=new c(this.content),this.$horizScroll=!1,this.$vScroll=!1,this.scrollBar=this.scrollBarV=new h(this.container,this),this.scrollBarH=new l(this.container,this),this.scrollBarV.on("scroll",function(A){S.$scrollAnimation||S.session.setScrollTop(A.data-S.scrollMargin.top)}),this.scrollBarH.on("scroll",function(A){S.$scrollAnimation||S.session.setScrollLeft(A.data-S.scrollMargin.left)}),this.scrollTop=0,this.scrollLeft=0,this.cursorPos={row:0,column:0},this.$fontMetrics=new v(this.container),this.$textLayer.$setFontMetrics(this.$fontMetrics),this.$textLayer.on("changeCharacterSize",function(A){S.updateCharacterSize(),S.onResize(!0,S.gutterWidth,S.$size.width,S.$size.height),S._signal("changeCharacterSize",A)}),this.$size={width:0,height:0,scrollerHeight:0,scrollerWidth:0,$dirty:!0},this.layerConfig={width:1,padding:0,firstRow:0,firstRowScreen:0,lastRow:0,lineHeight:0,characterWidth:0,minHeight:1,maxHeight:1,offset:0,height:1,gutterOffset:1},this.scrollMargin={left:0,right:0,top:0,bottom:0,v:0,h:0},this.margin={left:0,right:0,top:0,bottom:0,v:0,h:0},this.$keepTextAreaAtCursor=!w.isIOS,this.$loop=new _(this.$renderChanges.bind(this),this.container.ownerDocument.defaultView),this.$loop.schedule(this.CHANGE_FULL),this.updateCharacterSize(),this.setPadding(4),this.$addResizeObserver(),f.resetOptions(this),f._signal("renderer",this)}return N.prototype.updateCharacterSize=function(){this.$textLayer.allowBoldFonts!=this.$allowBoldFonts&&(this.$allowBoldFonts=this.$textLayer.allowBoldFonts,this.setStyle("ace_nobold",!this.$allowBoldFonts)),this.layerConfig.characterWidth=this.characterWidth=this.$textLayer.getCharacterWidth(),this.layerConfig.lineHeight=this.lineHeight=this.$textLayer.getLineHeight(),this.$updatePrintMargin(),P.setStyle(this.scroller.style,"line-height",this.lineHeight+"px")},N.prototype.setSession=function(D){this.session&&this.session.doc.off("changeNewLineMode",this.onChangeNewLineMode),this.session=D,D&&this.scrollMargin.top&&D.getScrollTop()<=0&&D.setScrollTop(-this.scrollMargin.top),this.$cursorLayer.setSession(D),this.$markerBack.setSession(D),this.$markerFront.setSession(D),this.$gutterLayer.setSession(D),this.$textLayer.setSession(D),D&&(this.$loop.schedule(this.CHANGE_FULL),this.session.$setFontMetrics(this.$fontMetrics),this.scrollBarH.scrollLeft=this.scrollBarV.scrollTop=null,this.onChangeNewLineMode=this.onChangeNewLineMode.bind(this),this.onChangeNewLineMode(),this.session.doc.on("changeNewLineMode",this.onChangeNewLineMode))},N.prototype.updateLines=function(D,R,S){if(R===void 0&&(R=1/0),this.$changedLines?(this.$changedLines.firstRow>D&&(this.$changedLines.firstRow=D),this.$changedLines.lastRowthis.layerConfig.lastRow||this.$loop.schedule(this.CHANGE_LINES)},N.prototype.onChangeNewLineMode=function(){this.$loop.schedule(this.CHANGE_TEXT),this.$textLayer.$updateEolChar(),this.session.$bidiHandler.setEolChar(this.$textLayer.EOL_CHAR)},N.prototype.onChangeTabSize=function(){this.$loop.schedule(this.CHANGE_TEXT|this.CHANGE_MARKER),this.$textLayer.onChangeTabSize()},N.prototype.updateText=function(){this.$loop.schedule(this.CHANGE_TEXT)},N.prototype.updateFull=function(D){D?this.$renderChanges(this.CHANGE_FULL,!0):this.$loop.schedule(this.CHANGE_FULL)},N.prototype.updateFontSize=function(){this.$textLayer.checkForSizeChanges()},N.prototype.$updateSizeAsync=function(){this.$loop.pending?this.$size.$dirty=!0:this.onResize()},N.prototype.onResize=function(D,R,S,F){if(!(this.resizing>2)){this.resizing>0?this.resizing++:this.resizing=D?1:0;var A=this.container;F||(F=A.clientHeight||A.scrollHeight),S||(S=A.clientWidth||A.scrollWidth);var E=this.$updateCachedSize(D,R,S,F);if(this.$resizeTimer&&this.$resizeTimer.cancel(),!this.$size.scrollerHeight||!S&&!F)return this.resizing=0;D&&(this.$gutterLayer.$padding=null),D?this.$renderChanges(E|this.$changes,!0):this.$loop.schedule(E|this.$changes),this.resizing&&(this.resizing=0),this.scrollBarH.scrollLeft=this.scrollBarV.scrollTop=null,this.$customScrollbar&&this.$updateCustomScrollbar(!0)}},N.prototype.$updateCachedSize=function(D,R,S,F){F-=this.$extraHeight||0;var A=0,E=this.$size,O={width:E.width,height:E.height,scrollerHeight:E.scrollerHeight,scrollerWidth:E.scrollerWidth};if(F&&(D||E.height!=F)&&(E.height=F,A|=this.CHANGE_SIZE,E.scrollerHeight=E.height,this.$horizScroll&&(E.scrollerHeight-=this.scrollBarH.getHeight()),this.scrollBarV.setHeight(E.scrollerHeight),this.scrollBarV.element.style.bottom=this.scrollBarH.getHeight()+"px",A=A|this.CHANGE_SCROLL),S&&(D||E.width!=S)){A|=this.CHANGE_SIZE,E.width=S,R==null&&(R=this.$showGutter?this.$gutter.offsetWidth:0),this.gutterWidth=R,P.setStyle(this.scrollBarH.element.style,"left",R+"px"),P.setStyle(this.scroller.style,"left",R+this.margin.left+"px"),E.scrollerWidth=Math.max(0,S-R-this.scrollBarV.getWidth()-this.margin.h),P.setStyle(this.$gutter.style,"left",this.margin.left+"px");var k=this.scrollBarV.getWidth()+"px";P.setStyle(this.scrollBarH.element.style,"right",k),P.setStyle(this.scroller.style,"right",k),P.setStyle(this.scroller.style,"bottom",this.scrollBarH.getHeight()),this.scrollBarH.setWidth(E.scrollerWidth),(this.session&&this.session.getUseWrapMode()&&this.adjustWrapLimit()||D)&&(A|=this.CHANGE_FULL)}return E.$dirty=!S||!F,A&&this._signal("resize",O),A},N.prototype.onGutterResize=function(D){var R=this.$showGutter?D:0;R!=this.gutterWidth&&(this.$changes|=this.$updateCachedSize(!0,R,this.$size.width,this.$size.height)),this.session.getUseWrapMode()&&this.adjustWrapLimit()?this.$loop.schedule(this.CHANGE_FULL):this.$size.$dirty?this.$loop.schedule(this.CHANGE_FULL):this.$computeLayerConfig()},N.prototype.adjustWrapLimit=function(){var D=this.$size.scrollerWidth-this.$padding*2,R=Math.floor(D/this.characterWidth);return this.session.adjustWrapLimit(R,this.$showPrintMargin&&this.$printMarginColumn)},N.prototype.setAnimatedScroll=function(D){this.setOption("animatedScroll",D)},N.prototype.getAnimatedScroll=function(){return this.$animatedScroll},N.prototype.setShowInvisibles=function(D){this.setOption("showInvisibles",D),this.session.$bidiHandler.setShowInvisibles(D)},N.prototype.getShowInvisibles=function(){return this.getOption("showInvisibles")},N.prototype.getDisplayIndentGuide=function(){return this.getOption("displayIndentGuides")},N.prototype.setDisplayIndentGuides=function(D){this.setOption("displayIndentGuides",D)},N.prototype.getHighlightIndentGuides=function(){return this.getOption("highlightIndentGuides")},N.prototype.setHighlightIndentGuides=function(D){this.setOption("highlightIndentGuides",D)},N.prototype.setShowPrintMargin=function(D){this.setOption("showPrintMargin",D)},N.prototype.getShowPrintMargin=function(){return this.getOption("showPrintMargin")},N.prototype.setPrintMarginColumn=function(D){this.setOption("printMarginColumn",D)},N.prototype.getPrintMarginColumn=function(){return this.getOption("printMarginColumn")},N.prototype.getShowGutter=function(){return this.getOption("showGutter")},N.prototype.setShowGutter=function(D){return this.setOption("showGutter",D)},N.prototype.getFadeFoldWidgets=function(){return this.getOption("fadeFoldWidgets")},N.prototype.setFadeFoldWidgets=function(D){this.setOption("fadeFoldWidgets",D)},N.prototype.setHighlightGutterLine=function(D){this.setOption("highlightGutterLine",D)},N.prototype.getHighlightGutterLine=function(){return this.getOption("highlightGutterLine")},N.prototype.$updatePrintMargin=function(){if(!(!this.$showPrintMargin&&!this.$printMarginEl)){if(!this.$printMarginEl){var D=P.createElement("div");D.className="ace_layer ace_print-margin-layer",this.$printMarginEl=P.createElement("div"),this.$printMarginEl.className="ace_print-margin",D.appendChild(this.$printMarginEl),this.content.insertBefore(D,this.content.firstChild)}var R=this.$printMarginEl.style;R.left=Math.round(this.characterWidth*this.$printMarginColumn+this.$padding)+"px",R.visibility=this.$showPrintMargin?"visible":"hidden",this.session&&this.session.$wrap==-1&&this.adjustWrapLimit()}},N.prototype.getContainerElement=function(){return this.container},N.prototype.getMouseEventTarget=function(){return this.scroller},N.prototype.getTextAreaContainer=function(){return this.container},N.prototype.$moveTextAreaToCursor=function(){if(!this.$isMousePressed){var D=this.textarea.style,R=this.$composition;if(!this.$keepTextAreaAtCursor&&!R){P.translate(this.textarea,-100,0);return}var S=this.$cursorLayer.$pixelPos;if(S){R&&R.markerRange&&(S=this.$cursorLayer.getPixelPosition(R.markerRange.start,!0));var F=this.layerConfig,A=S.top,E=S.left;A-=F.offset;var O=R&&R.useTextareaForIME||w.isMobile?this.lineHeight:1;if(A<0||A>F.height-O){P.translate(this.textarea,0,0);return}var k=1,H=this.$size.height-O;if(!R)A+=this.lineHeight;else if(R.useTextareaForIME){var V=this.textarea.value;k=this.characterWidth*this.session.$getStringScreenWidth(V)[0]}else A+=this.lineHeight+2;E-=this.scrollLeft,E>this.$size.scrollerWidth-k&&(E=this.$size.scrollerWidth-k),E+=this.gutterWidth+this.margin.left,P.setStyle(D,"height",O+"px"),P.setStyle(D,"width",k+"px"),P.translate(this.textarea,Math.min(E,this.$size.scrollerWidth-k),Math.min(A,H))}}},N.prototype.getFirstVisibleRow=function(){return this.layerConfig.firstRow},N.prototype.getFirstFullyVisibleRow=function(){return this.layerConfig.firstRow+(this.layerConfig.offset===0?0:1)},N.prototype.getLastFullyVisibleRow=function(){var D=this.layerConfig,R=D.lastRow,S=this.session.documentToScreenRow(R,0)*D.lineHeight;return S-this.session.getScrollTop()>D.height-D.lineHeight?R-1:R},N.prototype.getLastVisibleRow=function(){return this.layerConfig.lastRow},N.prototype.setPadding=function(D){this.$padding=D,this.$textLayer.setPadding(D),this.$cursorLayer.setPadding(D),this.$markerFront.setPadding(D),this.$markerBack.setPadding(D),this.$loop.schedule(this.CHANGE_FULL),this.$updatePrintMargin()},N.prototype.setScrollMargin=function(D,R,S,F){var A=this.scrollMargin;A.top=D|0,A.bottom=R|0,A.right=F|0,A.left=S|0,A.v=A.top+A.bottom,A.h=A.left+A.right,A.top&&this.scrollTop<=0&&this.session&&this.session.setScrollTop(-A.top),this.updateFull()},N.prototype.setMargin=function(D,R,S,F){var A=this.margin;A.top=D|0,A.bottom=R|0,A.right=F|0,A.left=S|0,A.v=A.top+A.bottom,A.h=A.left+A.right,this.$updateCachedSize(!0,this.gutterWidth,this.$size.width,this.$size.height),this.updateFull()},N.prototype.getHScrollBarAlwaysVisible=function(){return this.$hScrollBarAlwaysVisible},N.prototype.setHScrollBarAlwaysVisible=function(D){this.setOption("hScrollBarAlwaysVisible",D)},N.prototype.getVScrollBarAlwaysVisible=function(){return this.$vScrollBarAlwaysVisible},N.prototype.setVScrollBarAlwaysVisible=function(D){this.setOption("vScrollBarAlwaysVisible",D)},N.prototype.$updateScrollBarV=function(){var D=this.layerConfig.maxHeight,R=this.$size.scrollerHeight;!this.$maxLines&&this.$scrollPastEnd&&(D-=(R-this.lineHeight)*this.$scrollPastEnd,this.scrollTop>D-R&&(D=this.scrollTop+R,this.scrollBarV.scrollTop=null)),this.scrollBarV.setScrollHeight(D+this.scrollMargin.v),this.scrollBarV.setScrollTop(this.scrollTop+this.scrollMargin.top)},N.prototype.$updateScrollBarH=function(){this.scrollBarH.setScrollWidth(this.layerConfig.width+2*this.$padding+this.scrollMargin.h),this.scrollBarH.setScrollLeft(this.scrollLeft+this.scrollMargin.left)},N.prototype.freeze=function(){this.$frozen=!0},N.prototype.unfreeze=function(){this.$frozen=!1},N.prototype.$renderChanges=function(D,R){if(this.$changes&&(D|=this.$changes,this.$changes=0),!this.session||!this.container.offsetWidth||this.$frozen||!D&&!R){this.$changes|=D;return}if(this.$size.$dirty)return this.$changes|=D,this.onResize(!0);this.lineHeight||this.$textLayer.checkForSizeChanges(),this._signal("beforeRender",D),this.session&&this.session.$bidiHandler&&this.session.$bidiHandler.updateCharacterWidths(this.$fontMetrics);var S=this.layerConfig;if(D&this.CHANGE_FULL||D&this.CHANGE_SIZE||D&this.CHANGE_TEXT||D&this.CHANGE_LINES||D&this.CHANGE_SCROLL||D&this.CHANGE_H_SCROLL){if(D|=this.$computeLayerConfig()|this.$loop.clear(),S.firstRow!=this.layerConfig.firstRow&&S.firstRowScreen==this.layerConfig.firstRowScreen){var F=this.scrollTop+(S.firstRow-Math.max(this.layerConfig.firstRow,0))*this.lineHeight;F>0&&(this.scrollTop=F,D=D|this.CHANGE_SCROLL,D|=this.$computeLayerConfig()|this.$loop.clear())}S=this.layerConfig,this.$updateScrollBarV(),D&this.CHANGE_H_SCROLL&&this.$updateScrollBarH(),P.translate(this.content,-this.scrollLeft,-S.offset);var A=S.width+2*this.$padding+"px",E=S.minHeight+"px";P.setStyle(this.content.style,"width",A),P.setStyle(this.content.style,"height",E)}if(D&this.CHANGE_H_SCROLL&&(P.translate(this.content,-this.scrollLeft,-S.offset),this.scroller.className=this.scrollLeft<=0?"ace_scroller ":"ace_scroller ace_scroll-left ",this.enableKeyboardAccessibility&&(this.scroller.className+=this.keyboardFocusClassName)),D&this.CHANGE_FULL){this.$changedLines=null,this.$textLayer.update(S),this.$showGutter&&this.$gutterLayer.update(S),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(S),this.$markerBack.update(S),this.$markerFront.update(S),this.$cursorLayer.update(S),this.$moveTextAreaToCursor(),this._signal("afterRender",D);return}if(D&this.CHANGE_SCROLL){this.$changedLines=null,D&this.CHANGE_TEXT||D&this.CHANGE_LINES?this.$textLayer.update(S):this.$textLayer.scrollLines(S),this.$showGutter&&(D&this.CHANGE_GUTTER||D&this.CHANGE_LINES?this.$gutterLayer.update(S):this.$gutterLayer.scrollLines(S)),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(S),this.$markerBack.update(S),this.$markerFront.update(S),this.$cursorLayer.update(S),this.$moveTextAreaToCursor(),this._signal("afterRender",D);return}D&this.CHANGE_TEXT?(this.$changedLines=null,this.$textLayer.update(S),this.$showGutter&&this.$gutterLayer.update(S),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(S)):D&this.CHANGE_LINES?((this.$updateLines()||D&this.CHANGE_GUTTER&&this.$showGutter)&&this.$gutterLayer.update(S),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(S)):D&this.CHANGE_TEXT||D&this.CHANGE_GUTTER?(this.$showGutter&&this.$gutterLayer.update(S),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(S)):D&this.CHANGE_CURSOR&&(this.$highlightGutterLine&&this.$gutterLayer.updateLineHighlight(S),this.$customScrollbar&&this.$scrollDecorator.$updateDecorators(S)),D&this.CHANGE_CURSOR&&(this.$cursorLayer.update(S),this.$moveTextAreaToCursor()),D&(this.CHANGE_MARKER|this.CHANGE_MARKER_FRONT)&&this.$markerFront.update(S),D&(this.CHANGE_MARKER|this.CHANGE_MARKER_BACK)&&this.$markerBack.update(S),this._signal("afterRender",D)},N.prototype.$autosize=function(){var D=this.session.getScreenLength()*this.lineHeight,R=this.$maxLines*this.lineHeight,S=Math.min(R,Math.max((this.$minLines||1)*this.lineHeight,D))+this.scrollMargin.v+(this.$extraHeight||0);this.$horizScroll&&(S+=this.scrollBarH.getHeight()),this.$maxPixelHeight&&S>this.$maxPixelHeight&&(S=this.$maxPixelHeight);var F=S<=2*this.lineHeight,A=!F&&D>R;if(S!=this.desiredHeight||this.$size.height!=this.desiredHeight||A!=this.$vScroll){A!=this.$vScroll&&(this.$vScroll=A,this.scrollBarV.setVisible(A));var E=this.container.clientWidth;this.container.style.height=S+"px",this.$updateCachedSize(!0,this.$gutterWidth,E,S),this.desiredHeight=S,this._signal("autosize")}},N.prototype.$computeLayerConfig=function(){var D=this.session,R=this.$size,S=R.height<=2*this.lineHeight,F=this.session.getScreenLength(),A=F*this.lineHeight,E=this.$getLongestLine(),O=!S&&(this.$hScrollBarAlwaysVisible||R.scrollerWidth-E-2*this.$padding<0),k=this.$horizScroll!==O;k&&(this.$horizScroll=O,this.scrollBarH.setVisible(O));var H=this.$vScroll;this.$maxLines&&this.lineHeight>1&&this.$autosize();var V=R.scrollerHeight+this.lineHeight,W=!this.$maxLines&&this.$scrollPastEnd?(R.scrollerHeight-this.lineHeight)*this.$scrollPastEnd:0;A+=W;var K=this.scrollMargin;this.session.setScrollTop(Math.max(-K.top,Math.min(this.scrollTop,A-R.scrollerHeight+K.bottom))),this.session.setScrollLeft(Math.max(-K.left,Math.min(this.scrollLeft,E+2*this.$padding-R.scrollerWidth+K.right)));var Q=!S&&(this.$vScrollBarAlwaysVisible||R.scrollerHeight-A+W<0||this.scrollTop>K.top),ie=H!==Q;ie&&(this.$vScroll=Q,this.scrollBarV.setVisible(Q));var J=this.scrollTop%this.lineHeight,Y=Math.ceil(V/this.lineHeight)-1,z=Math.max(0,Math.round((this.scrollTop-J)/this.lineHeight)),oe=z+Y,he,de,fe=this.lineHeight;z=D.screenToDocumentRow(z,0);var le=D.getFoldLine(z);le&&(z=le.start.row),he=D.documentToScreenRow(z,0),de=D.getRowLength(z)*fe,oe=Math.min(D.screenToDocumentRow(oe,0),D.getLength()-1),V=R.scrollerHeight+D.getRowLength(oe)*fe+de,J=this.scrollTop-he*fe;var Re=0;return(this.layerConfig.width!=E||k)&&(Re=this.CHANGE_H_SCROLL),(k||ie)&&(Re|=this.$updateCachedSize(!0,this.gutterWidth,R.width,R.height),this._signal("scrollbarVisibilityChanged"),ie&&(E=this.$getLongestLine())),this.layerConfig={width:E,padding:this.$padding,firstRow:z,firstRowScreen:he,lastRow:oe,lineHeight:fe,characterWidth:this.characterWidth,minHeight:V,maxHeight:A,offset:J,gutterOffset:fe?Math.max(0,Math.ceil((J+R.height-R.scrollerHeight)/fe)):0,height:this.$size.scrollerHeight},this.session.$bidiHandler&&this.session.$bidiHandler.setContentWidth(E-this.$padding),Re},N.prototype.$updateLines=function(){if(this.$changedLines){var D=this.$changedLines.firstRow,R=this.$changedLines.lastRow;this.$changedLines=null;var S=this.layerConfig;if(!(D>S.lastRow+1)&&!(Rthis.$textLayer.MAX_LINE_LENGTH&&(D=this.$textLayer.MAX_LINE_LENGTH+30),Math.max(this.$size.scrollerWidth-2*this.$padding,Math.round(D*this.characterWidth))},N.prototype.updateFrontMarkers=function(){this.$markerFront.setMarkers(this.session.getMarkers(!0)),this.$loop.schedule(this.CHANGE_MARKER_FRONT)},N.prototype.updateBackMarkers=function(){this.$markerBack.setMarkers(this.session.getMarkers()),this.$loop.schedule(this.CHANGE_MARKER_BACK)},N.prototype.addGutterDecoration=function(D,R){this.$gutterLayer.addGutterDecoration(D,R)},N.prototype.removeGutterDecoration=function(D,R){this.$gutterLayer.removeGutterDecoration(D,R)},N.prototype.updateBreakpoints=function(D){this.$loop.schedule(this.CHANGE_GUTTER)},N.prototype.setAnnotations=function(D){this.$gutterLayer.setAnnotations(D),this.$loop.schedule(this.CHANGE_GUTTER)},N.prototype.updateCursor=function(){this.$loop.schedule(this.CHANGE_CURSOR)},N.prototype.hideCursor=function(){this.$cursorLayer.hideCursor()},N.prototype.showCursor=function(){this.$cursorLayer.showCursor()},N.prototype.scrollSelectionIntoView=function(D,R,S){this.scrollCursorIntoView(D,S),this.scrollCursorIntoView(R,S)},N.prototype.scrollCursorIntoView=function(D,R,S){if(this.$size.scrollerHeight!==0){var F=this.$cursorLayer.getPixelPosition(D),A=F.left,E=F.top,O=S&&S.top||0,k=S&&S.bottom||0;this.$scrollAnimation&&(this.$stopAnimation=!0);var H=this.$scrollAnimation?this.session.getScrollTop():this.scrollTop;H+O>E?(R&&H+O>E+this.lineHeight&&(E-=R*this.$size.scrollerHeight),E===0&&(E=-this.scrollMargin.top),this.session.setScrollTop(E)):H+this.$size.scrollerHeight-k=1-this.scrollMargin.top||R>0&&this.session.getScrollTop()+this.$size.scrollerHeight-this.layerConfig.maxHeight<-1+this.scrollMargin.bottom||D<0&&this.session.getScrollLeft()>=1-this.scrollMargin.left||D>0&&this.session.getScrollLeft()+this.$size.scrollerWidth-this.layerConfig.width<-1+this.scrollMargin.right)return!0},N.prototype.pixelToScreenCoordinates=function(D,R){var S;if(this.$hasCssTransforms){S={top:0,left:0};var F=this.$fontMetrics.transformCoordinates([D,R]);D=F[1]-this.gutterWidth-this.margin.left,R=F[0]}else S=this.scroller.getBoundingClientRect();var A=D+this.scrollLeft-S.left-this.$padding,E=A/this.characterWidth,O=Math.floor((R+this.scrollTop-S.top)/this.lineHeight),k=this.$blockCursor?Math.floor(E):Math.round(E);return{row:O,column:k,side:E-k>0?1:-1,offsetX:A}},N.prototype.screenToTextCoordinates=function(D,R){var S;if(this.$hasCssTransforms){S={top:0,left:0};var F=this.$fontMetrics.transformCoordinates([D,R]);D=F[1]-this.gutterWidth-this.margin.left,R=F[0]}else S=this.scroller.getBoundingClientRect();var A=D+this.scrollLeft-S.left-this.$padding,E=A/this.characterWidth,O=this.$blockCursor?Math.floor(E):Math.round(E),k=Math.floor((R+this.scrollTop-S.top)/this.lineHeight);return this.session.screenToDocumentPosition(k,Math.max(O,0),A)},N.prototype.textToScreenCoordinates=function(D,R){var S=this.scroller.getBoundingClientRect(),F=this.session.documentToScreenPosition(D,R),A=this.$padding+(this.session.$bidiHandler.isBidiRow(F.row,D)?this.session.$bidiHandler.getPosLeft(F.column):Math.round(F.column*this.characterWidth)),E=F.row*this.lineHeight;return{pageX:S.left+A-this.scrollLeft,pageY:S.top+E-this.scrollTop}},N.prototype.visualizeFocus=function(){P.addCssClass(this.container,"ace_focus")},N.prototype.visualizeBlur=function(){P.removeCssClass(this.container,"ace_focus")},N.prototype.showComposition=function(D){this.$composition=D,D.cssText||(D.cssText=this.textarea.style.cssText),D.useTextareaForIME==null&&(D.useTextareaForIME=this.$useTextareaForIME),this.$useTextareaForIME?(P.addCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText="",this.$moveTextAreaToCursor(),this.$cursorLayer.element.style.display="none"):D.markerId=this.session.addMarker(D.markerRange,"ace_composition_marker","text")},N.prototype.setCompositionText=function(D){var R=this.session.selection.cursor;this.addToken(D,"composition_placeholder",R.row,R.column),this.$moveTextAreaToCursor()},N.prototype.hideComposition=function(){if(this.$composition){this.$composition.markerId&&this.session.removeMarker(this.$composition.markerId),P.removeCssClass(this.textarea,"ace_composition"),this.textarea.style.cssText=this.$composition.cssText;var D=this.session.selection.cursor;this.removeExtraToken(D.row,D.column),this.$composition=null,this.$cursorLayer.element.style.display=""}},N.prototype.setGhostText=function(D,R){var S=this.session.selection.cursor,F=R||{row:S.row,column:S.column};this.removeGhostText();var A=D.split(` `);this.addToken(A[0],"ghost_text",F.row,F.column),this.$ghostText={text:D,position:{row:F.row,column:F.column}},A.length>1&&(this.$ghostTextWidget={text:A.slice(1).join(` -`),row:F.row,column:F.column,className:"ace_ghost_text"},this.session.widgetManager.addLineWidget(this.$ghostTextWidget))},N.prototype.removeGhostText=function(){if(this.$ghostText){var D=this.$ghostText.position;this.removeExtraToken(D.row,D.column),this.$ghostTextWidget&&(this.session.widgetManager.removeLineWidget(this.$ghostTextWidget),this.$ghostTextWidget=null),this.$ghostText=null}},N.prototype.addToken=function(D,R,w,F){var A=this.session;A.bgTokenizer.lines[w]=null;var T={type:R,value:D},L=A.getTokens(w);if(F==null||!L.length)L.push(T);else for(var O=0,H=0;H1||Math.abs(D.$size.height-F)>1?D.$resizeTimer.delay():D.$resizeTimer.cancel()}),this.$resizeObserver.observe(this.container)}},N}();x.prototype.CHANGE_CURSOR=1,x.prototype.CHANGE_MARKER=2,x.prototype.CHANGE_GUTTER=4,x.prototype.CHANGE_SCROLL=8,x.prototype.CHANGE_LINES=16,x.prototype.CHANGE_TEXT=32,x.prototype.CHANGE_SIZE=64,x.prototype.CHANGE_MARKER_BACK=128,x.prototype.CHANGE_MARKER_FRONT=256,x.prototype.CHANGE_FULL=512,x.prototype.CHANGE_H_SCROLL=1024,x.prototype.$changes=0,x.prototype.$padding=null,x.prototype.$frozen=!1,x.prototype.STEPS=8,B.implement(x.prototype,k),f.defineOptions(x.prototype,"renderer",{useResizeObserver:{set:function(N){!N&&this.$resizeObserver?(this.$resizeObserver.disconnect(),this.$resizeTimer.cancel(),this.$resizeTimer=this.$resizeObserver=null):N&&!this.$resizeObserver&&this.$addResizeObserver()}},animatedScroll:{initialValue:!1},showInvisibles:{set:function(N){this.$textLayer.setShowInvisibles(N)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!1},showPrintMargin:{set:function(){this.$updatePrintMargin()},initialValue:!0},printMarginColumn:{set:function(){this.$updatePrintMargin()},initialValue:80},printMargin:{set:function(N){typeof N=="number"&&(this.$printMarginColumn=N),this.$showPrintMargin=!!N,this.$updatePrintMargin()},get:function(){return this.$showPrintMargin&&this.$printMarginColumn}},showGutter:{set:function(N){this.$gutter.style.display=N?"block":"none",this.$loop.schedule(this.CHANGE_FULL),this.onGutterResize()},initialValue:!0},useSvgGutterIcons:{set:function(N){this.$gutterLayer.$useSvgGutterIcons=N},initialValue:!1},showFoldedAnnotations:{set:function(N){this.$gutterLayer.$showFoldedAnnotations=N},initialValue:!1},fadeFoldWidgets:{set:function(N){P.setCssClass(this.$gutter,"ace_fade-fold-widgets",N)},initialValue:!1},showFoldWidgets:{set:function(N){this.$gutterLayer.setShowFoldWidgets(N),this.$loop.schedule(this.CHANGE_GUTTER)},initialValue:!0},displayIndentGuides:{set:function(N){this.$textLayer.setDisplayIndentGuides(N)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!0},highlightIndentGuides:{set:function(N){this.$textLayer.setHighlightIndentGuides(N)==!0?this.$textLayer.$highlightIndentGuide():this.$textLayer.$clearActiveIndentGuide(this.$textLayer.$lines.cells)},initialValue:!0},highlightGutterLine:{set:function(N){this.$gutterLayer.setHighlightGutterLine(N),this.$loop.schedule(this.CHANGE_GUTTER)},initialValue:!0},hScrollBarAlwaysVisible:{set:function(N){(!this.$hScrollBarAlwaysVisible||!this.$horizScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},vScrollBarAlwaysVisible:{set:function(N){(!this.$vScrollBarAlwaysVisible||!this.$vScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},fontSize:{set:function(N){typeof N=="number"&&(N=N+"px"),this.container.style.fontSize=N,this.updateFontSize()},initialValue:12},fontFamily:{set:function(N){this.container.style.fontFamily=N,this.updateFontSize()}},maxLines:{set:function(N){this.updateFull()}},minLines:{set:function(N){this.$minLines<562949953421311||(this.$minLines=0),this.updateFull()}},maxPixelHeight:{set:function(N){this.updateFull()},initialValue:0},scrollPastEnd:{set:function(N){N=+N||0,this.$scrollPastEnd!=N&&(this.$scrollPastEnd=N,this.$loop.schedule(this.CHANGE_SCROLL))},initialValue:0,handlesSet:!0},fixedWidthGutter:{set:function(N){this.$gutterLayer.$fixedWidth=!!N,this.$loop.schedule(this.CHANGE_GUTTER)}},customScrollbar:{set:function(N){this.$updateCustomScrollbar(N)},initialValue:!1},theme:{set:function(N){this.setTheme(N)},get:function(){return this.$themeId||this.theme},initialValue:"./theme/textmate",handlesSet:!0},hasCssTransforms:{},useTextareaForIME:{initialValue:!b.isMobile&&!b.isIE}}),p.VirtualRenderer=x}),ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"],function(r,p,m){var B=r("../lib/oop"),P=r("../lib/net"),C=r("../lib/event_emitter").EventEmitter,f=r("../config");function a(l){var h="importScripts('"+P.qualifyURL(l)+"');";try{return new Blob([h],{type:"application/javascript"})}catch{var d=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,g=new d;return g.append(h),g.getBlob("application/javascript")}}function s(l){if(typeof Worker>"u")return{postMessage:function(){},terminate:function(){}};if(f.get("loadWorkerFromBlob")){var h=a(l),d=window.URL||window.webkitURL,g=d.createObjectURL(h);return new Worker(g)}return new Worker(l)}var o=function(l){l.postMessage||(l=this.$createWorkerFromOldConfig.apply(this,arguments)),this.$worker=l,this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.onMessage=this.onMessage.bind(this),this.callbackId=1,this.callbacks={},this.$worker.onmessage=this.onMessage};(function(){B.implement(this,C),this.$createWorkerFromOldConfig=function(l,h,d,g,_){if(r.nameToUrl&&!r.toUrl&&(r.toUrl=r.nameToUrl),f.get("packaged")||!r.toUrl)g=g||f.moduleUrl(h,"worker");else{var v=this.$normalizePath;g=g||v(r.toUrl("ace/worker/worker.js",null,"_"));var k={};l.forEach(function(I){k[I]=v(r.toUrl(I,null,"_").replace(/(\.js)?(\?.*)?$/,""))})}return this.$worker=s(g),_&&this.send("importScripts",_),this.$worker.postMessage({init:!0,tlns:k,module:h,classname:d}),this.$worker},this.onMessage=function(l){var h=l.data;switch(h.type){case"event":this._signal(h.name,{data:h.data});break;case"call":var d=this.callbacks[h.id];d&&(d(h.data),delete this.callbacks[h.id]);break;case"error":this.reportError(h.data);break;case"log":window.console&&console.log&&console.log.apply(console,h.data);break}},this.reportError=function(l){window.console&&console.error&&console.error(l)},this.$normalizePath=function(l){return P.qualifyURL(l)},this.terminate=function(){this._signal("terminate",{}),this.deltaQueue=null,this.$worker.terminate(),this.$worker=null,this.$doc&&this.$doc.off("change",this.changeListener),this.$doc=null},this.send=function(l,h){this.$worker.postMessage({command:l,args:h})},this.call=function(l,h,d){if(d){var g=this.callbackId++;this.callbacks[g]=d,h.push(g)}this.send(l,h)},this.emit=function(l,h){try{h.data&&h.data.err&&(h.data.err={message:h.data.err.message,stack:h.data.err.stack,code:h.data.err.code}),this.$worker&&this.$worker.postMessage({event:l,data:{data:h.data}})}catch(d){console.error(d.stack)}},this.attachToDocument=function(l){this.$doc&&this.terminate(),this.$doc=l,this.call("setValue",[l.getValue()]),l.on("change",this.changeListener,!0)},this.changeListener=function(l){this.deltaQueue||(this.deltaQueue=[],setTimeout(this.$sendDeltaQueue,0)),l.action=="insert"?this.deltaQueue.push(l.start,l.lines):this.deltaQueue.push(l.start,l.end)},this.$sendDeltaQueue=function(){var l=this.deltaQueue;l&&(this.deltaQueue=null,l.length>50&&l.length>this.$doc.getLength()>>1?this.call("setValue",[this.$doc.getValue()]):this.emit("change",{data:l}))}}).call(o.prototype);var c=function(l,h,d){var g=null,_=!1,v=Object.create(C),k=[],I=new o({messageBuffer:k,terminate:function(){},postMessage:function(b){k.push(b),g&&(_?setTimeout(S):S())}});I.setEmitSync=function(b){_=b};var S=function(){var b=k.shift();b.command?g[b.command].apply(g,b.args):b.event&&v._signal(b.event,b.data)};return v.postMessage=function(b){I.onMessage({data:b})},v.callback=function(b,x){this.postMessage({type:"call",id:x,data:b})},v.emit=function(b,x){this.postMessage({type:"event",name:b,data:x})},f.loadModule(["worker",h],function(b){for(g=new b[d](v);k.length;)S()}),I};p.UIWorkerClient=c,p.WorkerClient=o,p.createWorker=s}),ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"],function(r,p,m){var B=r("./range").Range,P=r("./lib/event_emitter").EventEmitter,C=r("./lib/oop"),f=function(){function a(s,o,c,l,h,d){var g=this;this.length=o,this.session=s,this.doc=s.getDocument(),this.mainClass=h,this.othersClass=d,this.$onUpdate=this.onUpdate.bind(this),this.doc.on("change",this.$onUpdate,!0),this.$others=l,this.$onCursorChange=function(){setTimeout(function(){g.onCursorChange()})},this.$pos=c;var _=s.getUndoManager().$undoStack||s.getUndoManager().$undostack||{length:-1};this.$undoStackDepth=_.length,this.setup(),s.selection.on("changeCursor",this.$onCursorChange)}return a.prototype.setup=function(){var s=this,o=this.doc,c=this.session;this.selectionBefore=c.selection.toJSON(),c.selection.inMultiSelectMode&&c.selection.toSingleRange(),this.pos=o.createAnchor(this.$pos.row,this.$pos.column);var l=this.pos;l.$insertRight=!0,l.detach(),l.markerId=c.addMarker(new B(l.row,l.column,l.row,l.column+this.length),this.mainClass,null,!1),this.others=[],this.$others.forEach(function(h){var d=o.createAnchor(h.row,h.column);d.$insertRight=!0,d.detach(),s.others.push(d)}),c.setUndoSelect(!1)},a.prototype.showOtherMarkers=function(){if(!this.othersActive){var s=this.session,o=this;this.othersActive=!0,this.others.forEach(function(c){c.markerId=s.addMarker(new B(c.row,c.column,c.row,c.column+o.length),o.othersClass,null,!1)})}},a.prototype.hideOtherMarkers=function(){if(this.othersActive){this.othersActive=!1;for(var s=0;s=this.pos.column&&o.start.column<=this.pos.column+this.length+1,h=o.start.column-this.pos.column;if(this.updateAnchors(s),l&&(this.length+=c),l&&!this.session.$fromUndo){if(s.action==="insert")for(var d=this.others.length-1;d>=0;d--){var g=this.others[d],_={row:g.row,column:g.column+h};this.doc.insertMergedLines(_,s.lines)}else if(s.action==="remove")for(var d=this.others.length-1;d>=0;d--){var g=this.others[d],_={row:g.row,column:g.column+h};this.doc.remove(new B(_.row,_.column,_.row,_.column-c))}}this.$updating=!1,this.updateMarkers()}},a.prototype.updateAnchors=function(s){this.pos.onChange(s);for(var o=this.others.length;o--;)this.others[o].onChange(s);this.updateMarkers()},a.prototype.updateMarkers=function(){if(!this.$updating){var s=this,o=this.session,c=function(h,d){o.removeMarker(h.markerId),h.markerId=o.addMarker(new B(h.row,h.column,h.row,h.column+s.length),d,null,!1)};c(this.pos,this.mainClass);for(var l=this.others.length;l--;)c(this.others[l],this.othersClass)}},a.prototype.onCursorChange=function(s){if(!(this.$updating||!this.session)){var o=this.session.selection.getCursor();o.row===this.pos.row&&o.column>=this.pos.column&&o.column<=this.pos.column+this.length?(this.showOtherMarkers(),this._emit("cursorEnter",s)):(this.hideOtherMarkers(),this._emit("cursorLeave",s))}},a.prototype.detach=function(){this.session.removeMarker(this.pos&&this.pos.markerId),this.hideOtherMarkers(),this.doc.off("change",this.$onUpdate),this.session.selection.off("changeCursor",this.$onCursorChange),this.session.setUndoSelect(!0),this.session=null},a.prototype.cancel=function(){if(this.$undoStackDepth!==-1){for(var s=this.session.getUndoManager(),o=(s.$undoStack||s.$undostack).length-this.$undoStackDepth,c=0;c1?P.multiSelect.joinSelections():P.multiSelect.splitIntoLines()},bindKey:{win:"Ctrl-Alt-L",mac:"Ctrl-Alt-L"},readOnly:!0},{name:"splitSelectionIntoLines",description:"Split into lines",exec:function(P){P.multiSelect.splitIntoLines()},readOnly:!0},{name:"alignCursors",description:"Align cursors",exec:function(P){P.alignCursors()},bindKey:{win:"Ctrl-Alt-A",mac:"Ctrl-Alt-A"},scrollIntoView:"cursor"},{name:"findAll",description:"Find all",exec:function(P){P.findAll()},bindKey:{win:"Ctrl-Alt-K",mac:"Ctrl-Alt-G"},scrollIntoView:"cursor",readOnly:!0}],p.multiSelectCommands=[{name:"singleSelection",description:"Single selection",bindKey:"esc",exec:function(P){P.exitMultiSelectMode()},scrollIntoView:"cursor",readOnly:!0,isAvailable:function(P){return P&&P.inMultiSelectMode}}];var B=r("../keyboard/hash_handler").HashHandler;p.keyboardHandler=new B(p.multiSelectCommands)}),ace.define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor","ace/config"],function(r,p,m){var B=r("./range_list").RangeList,P=r("./range").Range,C=r("./selection").Selection,f=r("./mouse/multi_select_handler").onMouseDown,a=r("./lib/event"),s=r("./lib/lang"),o=r("./commands/multi_select_commands");p.commands=o.defaultCommands.concat(o.multiSelectCommands);var c=r("./search").Search,l=new c;function h(I,S,b){return l.$options.wrap=!0,l.$options.needle=S,l.$options.backwards=b==-1,l.find(I)}var d=r("./edit_session").EditSession;(function(){this.getSelectionMarkers=function(){return this.$selectionMarkers}}).call(d.prototype),function(){this.ranges=null,this.rangeList=null,this.addRange=function(I,S){if(I){if(!this.inMultiSelectMode&&this.rangeCount===0){var b=this.toOrientedRange();if(this.rangeList.add(b),this.rangeList.add(I),this.rangeList.ranges.length!=2)return this.rangeList.removeAll(),S||this.fromOrientedRange(I);this.rangeList.removeAll(),this.rangeList.add(b),this.$onAddRange(b)}I.cursor||(I.cursor=I.end);var x=this.rangeList.add(I);return this.$onAddRange(I),x.length&&this.$onRemoveRange(x),this.rangeCount>1&&!this.inMultiSelectMode&&(this._signal("multiSelect"),this.inMultiSelectMode=!0,this.session.$undoSelect=!1,this.rangeList.attach(this.session)),S||this.fromOrientedRange(I)}},this.toSingleRange=function(I){I=I||this.ranges[0];var S=this.rangeList.removeAll();S.length&&this.$onRemoveRange(S),I&&this.fromOrientedRange(I)},this.substractPoint=function(I){var S=this.rangeList.substractPoint(I);if(S)return this.$onRemoveRange(S),S[0]},this.mergeOverlappingRanges=function(){var I=this.rangeList.merge();I.length&&this.$onRemoveRange(I)},this.$onAddRange=function(I){this.rangeCount=this.rangeList.ranges.length,this.ranges.unshift(I),this._signal("addRange",{range:I})},this.$onRemoveRange=function(I){if(this.rangeCount=this.rangeList.ranges.length,this.rangeCount==1&&this.inMultiSelectMode){var S=this.rangeList.ranges.pop();I.push(S),this.rangeCount=0}for(var b=I.length;b--;){var x=this.ranges.indexOf(I[b]);this.ranges.splice(x,1)}this._signal("removeRange",{ranges:I}),this.rangeCount===0&&this.inMultiSelectMode&&(this.inMultiSelectMode=!1,this._signal("singleSelect"),this.session.$undoSelect=!0,this.rangeList.detach(this.session)),S=S||this.ranges[0],S&&!S.isEqual(this.getRange())&&this.fromOrientedRange(S)},this.$initRangeList=function(){this.rangeList||(this.rangeList=new B,this.ranges=[],this.rangeCount=0)},this.getAllRanges=function(){return this.rangeCount?this.rangeList.ranges.concat():[this.getRange()]},this.splitIntoLines=function(){for(var I=this.ranges.length?this.ranges:[this.getRange()],S=[],b=0;b1){var I=this.rangeList.ranges,S=I[I.length-1],b=P.fromPoints(I[0].start,S.end);this.toSingleRange(),this.setSelectionRange(b,S.cursor==S.start)}else{var x=this.session.documentToScreenPosition(this.cursor),N=this.session.documentToScreenPosition(this.anchor),D=this.rectangularRangeBlock(x,N);D.forEach(this.addRange,this)}},this.rectangularRangeBlock=function(I,S,b){var x=[],N=I.column0;)W--;if(W>0)for(var K=0;x[K].isEmpty();)K++;for(var Q=W;Q>=K;Q--)x[Q].isEmpty()&&x.splice(Q,1)}return x}}.call(C.prototype);var g=r("./editor").Editor;(function(){this.updateSelectionMarkers=function(){this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.addSelectionMarker=function(I){I.cursor||(I.cursor=I.end);var S=this.getSelectionStyle();return I.marker=this.session.addMarker(I,"ace_selection",S),this.session.$selectionMarkers.push(I),this.session.selectionMarkerCount=this.session.$selectionMarkers.length,I},this.removeSelectionMarker=function(I){if(I.marker){this.session.removeMarker(I.marker);var S=this.session.$selectionMarkers.indexOf(I);S!=-1&&this.session.$selectionMarkers.splice(S,1),this.session.selectionMarkerCount=this.session.$selectionMarkers.length}},this.removeSelectionMarkers=function(I){for(var S=this.session.$selectionMarkers,b=I.length;b--;){var x=I[b];if(x.marker){this.session.removeMarker(x.marker);var N=S.indexOf(x);N!=-1&&S.splice(N,1)}}this.session.selectionMarkerCount=S.length},this.$onAddRange=function(I){this.addSelectionMarker(I.range),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onRemoveRange=function(I){this.removeSelectionMarkers(I.ranges),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onMultiSelect=function(I){this.inMultiSelectMode||(this.inMultiSelectMode=!0,this.setStyle("ace_multiselect"),this.keyBinding.addKeyboardHandler(o.keyboardHandler),this.commands.setDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers())},this.$onSingleSelect=function(I){this.session.multiSelect.inVirtualMode||(this.inMultiSelectMode=!1,this.unsetStyle("ace_multiselect"),this.keyBinding.removeKeyboardHandler(o.keyboardHandler),this.commands.removeDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers(),this._emit("changeSelection"))},this.$onMultiSelectExec=function(I){var S=I.command,b=I.editor;if(b.multiSelect){if(S.multiSelectAction)S.multiSelectAction=="forEach"?x=b.forEachSelection(S,I.args):S.multiSelectAction=="forEachLine"?x=b.forEachSelection(S,I.args,!0):S.multiSelectAction=="single"?(b.exitMultiSelectMode(),x=S.exec(b,I.args||{})):x=S.multiSelectAction(b,I.args||{});else{var x=S.exec(b,I.args||{});b.multiSelect.addRange(b.multiSelect.toOrientedRange()),b.multiSelect.mergeOverlappingRanges()}return x}},this.forEachSelection=function(I,S,b){if(!this.inVirtualSelectionMode){var x=b&&b.keepOrder,N=b==!0||b&&b.$byLines,D=this.session,R=this.selection,w=R.rangeList,F=(x?R:w).ranges,A;if(!F.length)return I.exec?I.exec(this,S||{}):I(this,S||{});var T=R._eventRegistry;R._eventRegistry={};var L=new C(D);this.inVirtualSelectionMode=!0;for(var O=F.length;O--;){if(N)for(;O>0&&F[O].start.row==F[O-1].end.row;)O--;L.fromOrientedRange(F[O]),L.index=O,this.selection=D.selection=L;var H=I.exec?I.exec(this,S||{}):I(this,S||{});!A&&H!==void 0&&(A=H),L.toOrientedRange(F[O])}L.detach(),this.selection=D.selection=R,this.inVirtualSelectionMode=!1,R._eventRegistry=T,R.mergeOverlappingRanges(),R.ranges[0]&&R.fromOrientedRange(R.ranges[0]);var V=this.renderer.$scrollAnimation;return this.onCursorChange(),this.onSelectionChange(),V&&V.from==V.to&&this.renderer.animateScrolling(V.from),A}},this.exitMultiSelectMode=function(){!this.inMultiSelectMode||this.inVirtualSelectionMode||this.multiSelect.toSingleRange()},this.getSelectedText=function(){var I="";if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){for(var S=this.multiSelect.rangeList.ranges,b=[],x=0;x0);R<0&&(R=0),w>=A&&(w=A-1)}var L=this.session.removeFullLines(R,w);L=this.$reAlignText(L,F),this.session.insert({row:R,column:0},L.join(` +`),row:F.row,column:F.column,className:"ace_ghost_text"},this.session.widgetManager.addLineWidget(this.$ghostTextWidget))},N.prototype.removeGhostText=function(){if(this.$ghostText){var D=this.$ghostText.position;this.removeExtraToken(D.row,D.column),this.$ghostTextWidget&&(this.session.widgetManager.removeLineWidget(this.$ghostTextWidget),this.$ghostTextWidget=null),this.$ghostText=null}},N.prototype.addToken=function(D,R,S,F){var A=this.session;A.bgTokenizer.lines[S]=null;var E={type:R,value:D},O=A.getTokens(S);if(F==null||!O.length)O.push(E);else for(var k=0,H=0;H1||Math.abs(D.$size.height-F)>1?D.$resizeTimer.delay():D.$resizeTimer.cancel()}),this.$resizeObserver.observe(this.container)}},N}();x.prototype.CHANGE_CURSOR=1,x.prototype.CHANGE_MARKER=2,x.prototype.CHANGE_GUTTER=4,x.prototype.CHANGE_SCROLL=8,x.prototype.CHANGE_LINES=16,x.prototype.CHANGE_TEXT=32,x.prototype.CHANGE_SIZE=64,x.prototype.CHANGE_MARKER_BACK=128,x.prototype.CHANGE_MARKER_FRONT=256,x.prototype.CHANGE_FULL=512,x.prototype.CHANGE_H_SCROLL=1024,x.prototype.$changes=0,x.prototype.$padding=null,x.prototype.$frozen=!1,x.prototype.STEPS=8,B.implement(x.prototype,M),f.defineOptions(x.prototype,"renderer",{useResizeObserver:{set:function(N){!N&&this.$resizeObserver?(this.$resizeObserver.disconnect(),this.$resizeTimer.cancel(),this.$resizeTimer=this.$resizeObserver=null):N&&!this.$resizeObserver&&this.$addResizeObserver()}},animatedScroll:{initialValue:!1},showInvisibles:{set:function(N){this.$textLayer.setShowInvisibles(N)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!1},showPrintMargin:{set:function(){this.$updatePrintMargin()},initialValue:!0},printMarginColumn:{set:function(){this.$updatePrintMargin()},initialValue:80},printMargin:{set:function(N){typeof N=="number"&&(this.$printMarginColumn=N),this.$showPrintMargin=!!N,this.$updatePrintMargin()},get:function(){return this.$showPrintMargin&&this.$printMarginColumn}},showGutter:{set:function(N){this.$gutter.style.display=N?"block":"none",this.$loop.schedule(this.CHANGE_FULL),this.onGutterResize()},initialValue:!0},useSvgGutterIcons:{set:function(N){this.$gutterLayer.$useSvgGutterIcons=N},initialValue:!1},showFoldedAnnotations:{set:function(N){this.$gutterLayer.$showFoldedAnnotations=N},initialValue:!1},fadeFoldWidgets:{set:function(N){P.setCssClass(this.$gutter,"ace_fade-fold-widgets",N)},initialValue:!1},showFoldWidgets:{set:function(N){this.$gutterLayer.setShowFoldWidgets(N),this.$loop.schedule(this.CHANGE_GUTTER)},initialValue:!0},displayIndentGuides:{set:function(N){this.$textLayer.setDisplayIndentGuides(N)&&this.$loop.schedule(this.CHANGE_TEXT)},initialValue:!0},highlightIndentGuides:{set:function(N){this.$textLayer.setHighlightIndentGuides(N)==!0?this.$textLayer.$highlightIndentGuide():this.$textLayer.$clearActiveIndentGuide(this.$textLayer.$lines.cells)},initialValue:!0},highlightGutterLine:{set:function(N){this.$gutterLayer.setHighlightGutterLine(N),this.$loop.schedule(this.CHANGE_GUTTER)},initialValue:!0},hScrollBarAlwaysVisible:{set:function(N){(!this.$hScrollBarAlwaysVisible||!this.$horizScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},vScrollBarAlwaysVisible:{set:function(N){(!this.$vScrollBarAlwaysVisible||!this.$vScroll)&&this.$loop.schedule(this.CHANGE_SCROLL)},initialValue:!1},fontSize:{set:function(N){typeof N=="number"&&(N=N+"px"),this.container.style.fontSize=N,this.updateFontSize()},initialValue:12},fontFamily:{set:function(N){this.container.style.fontFamily=N,this.updateFontSize()}},maxLines:{set:function(N){this.updateFull()}},minLines:{set:function(N){this.$minLines<562949953421311||(this.$minLines=0),this.updateFull()}},maxPixelHeight:{set:function(N){this.updateFull()},initialValue:0},scrollPastEnd:{set:function(N){N=+N||0,this.$scrollPastEnd!=N&&(this.$scrollPastEnd=N,this.$loop.schedule(this.CHANGE_SCROLL))},initialValue:0,handlesSet:!0},fixedWidthGutter:{set:function(N){this.$gutterLayer.$fixedWidth=!!N,this.$loop.schedule(this.CHANGE_GUTTER)}},customScrollbar:{set:function(N){this.$updateCustomScrollbar(N)},initialValue:!1},theme:{set:function(N){this.setTheme(N)},get:function(){return this.$themeId||this.theme},initialValue:"./theme/textmate",handlesSet:!0},hasCssTransforms:{},useTextareaForIME:{initialValue:!w.isMobile&&!w.isIE}}),p.VirtualRenderer=x}),ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"],function(s,p,m){var B=s("../lib/oop"),P=s("../lib/net"),C=s("../lib/event_emitter").EventEmitter,f=s("../config");function a(l){var h="importScripts('"+P.qualifyURL(l)+"');";try{return new Blob([h],{type:"application/javascript"})}catch{var d=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,g=new d;return g.append(h),g.getBlob("application/javascript")}}function r(l){if(typeof Worker>"u")return{postMessage:function(){},terminate:function(){}};if(f.get("loadWorkerFromBlob")){var h=a(l),d=window.URL||window.webkitURL,g=d.createObjectURL(h);return new Worker(g)}return new Worker(l)}var o=function(l){l.postMessage||(l=this.$createWorkerFromOldConfig.apply(this,arguments)),this.$worker=l,this.$sendDeltaQueue=this.$sendDeltaQueue.bind(this),this.changeListener=this.changeListener.bind(this),this.onMessage=this.onMessage.bind(this),this.callbackId=1,this.callbacks={},this.$worker.onmessage=this.onMessage};(function(){B.implement(this,C),this.$createWorkerFromOldConfig=function(l,h,d,g,_){if(s.nameToUrl&&!s.toUrl&&(s.toUrl=s.nameToUrl),f.get("packaged")||!s.toUrl)g=g||f.moduleUrl(h,"worker");else{var v=this.$normalizePath;g=g||v(s.toUrl("ace/worker/worker.js",null,"_"));var M={};l.forEach(function(y){M[y]=v(s.toUrl(y,null,"_").replace(/(\.js)?(\?.*)?$/,""))})}return this.$worker=r(g),_&&this.send("importScripts",_),this.$worker.postMessage({init:!0,tlns:M,module:h,classname:d}),this.$worker},this.onMessage=function(l){var h=l.data;switch(h.type){case"event":this._signal(h.name,{data:h.data});break;case"call":var d=this.callbacks[h.id];d&&(d(h.data),delete this.callbacks[h.id]);break;case"error":this.reportError(h.data);break;case"log":window.console&&console.log&&console.log.apply(console,h.data);break}},this.reportError=function(l){window.console&&console.error&&console.error(l)},this.$normalizePath=function(l){return P.qualifyURL(l)},this.terminate=function(){this._signal("terminate",{}),this.deltaQueue=null,this.$worker.terminate(),this.$worker=null,this.$doc&&this.$doc.off("change",this.changeListener),this.$doc=null},this.send=function(l,h){this.$worker.postMessage({command:l,args:h})},this.call=function(l,h,d){if(d){var g=this.callbackId++;this.callbacks[g]=d,h.push(g)}this.send(l,h)},this.emit=function(l,h){try{h.data&&h.data.err&&(h.data.err={message:h.data.err.message,stack:h.data.err.stack,code:h.data.err.code}),this.$worker&&this.$worker.postMessage({event:l,data:{data:h.data}})}catch(d){console.error(d.stack)}},this.attachToDocument=function(l){this.$doc&&this.terminate(),this.$doc=l,this.call("setValue",[l.getValue()]),l.on("change",this.changeListener,!0)},this.changeListener=function(l){this.deltaQueue||(this.deltaQueue=[],setTimeout(this.$sendDeltaQueue,0)),l.action=="insert"?this.deltaQueue.push(l.start,l.lines):this.deltaQueue.push(l.start,l.end)},this.$sendDeltaQueue=function(){var l=this.deltaQueue;l&&(this.deltaQueue=null,l.length>50&&l.length>this.$doc.getLength()>>1?this.call("setValue",[this.$doc.getValue()]):this.emit("change",{data:l}))}}).call(o.prototype);var c=function(l,h,d){var g=null,_=!1,v=Object.create(C),M=[],y=new o({messageBuffer:M,terminate:function(){},postMessage:function(w){M.push(w),g&&(_?setTimeout(I):I())}});y.setEmitSync=function(w){_=w};var I=function(){var w=M.shift();w.command?g[w.command].apply(g,w.args):w.event&&v._signal(w.event,w.data)};return v.postMessage=function(w){y.onMessage({data:w})},v.callback=function(w,x){this.postMessage({type:"call",id:x,data:w})},v.emit=function(w,x){this.postMessage({type:"event",name:w,data:x})},f.loadModule(["worker",h],function(w){for(g=new w[d](v);M.length;)I()}),y};p.UIWorkerClient=c,p.WorkerClient=o,p.createWorker=r}),ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"],function(s,p,m){var B=s("./range").Range,P=s("./lib/event_emitter").EventEmitter,C=s("./lib/oop"),f=function(){function a(r,o,c,l,h,d){var g=this;this.length=o,this.session=r,this.doc=r.getDocument(),this.mainClass=h,this.othersClass=d,this.$onUpdate=this.onUpdate.bind(this),this.doc.on("change",this.$onUpdate,!0),this.$others=l,this.$onCursorChange=function(){setTimeout(function(){g.onCursorChange()})},this.$pos=c;var _=r.getUndoManager().$undoStack||r.getUndoManager().$undostack||{length:-1};this.$undoStackDepth=_.length,this.setup(),r.selection.on("changeCursor",this.$onCursorChange)}return a.prototype.setup=function(){var r=this,o=this.doc,c=this.session;this.selectionBefore=c.selection.toJSON(),c.selection.inMultiSelectMode&&c.selection.toSingleRange(),this.pos=o.createAnchor(this.$pos.row,this.$pos.column);var l=this.pos;l.$insertRight=!0,l.detach(),l.markerId=c.addMarker(new B(l.row,l.column,l.row,l.column+this.length),this.mainClass,null,!1),this.others=[],this.$others.forEach(function(h){var d=o.createAnchor(h.row,h.column);d.$insertRight=!0,d.detach(),r.others.push(d)}),c.setUndoSelect(!1)},a.prototype.showOtherMarkers=function(){if(!this.othersActive){var r=this.session,o=this;this.othersActive=!0,this.others.forEach(function(c){c.markerId=r.addMarker(new B(c.row,c.column,c.row,c.column+o.length),o.othersClass,null,!1)})}},a.prototype.hideOtherMarkers=function(){if(this.othersActive){this.othersActive=!1;for(var r=0;r=this.pos.column&&o.start.column<=this.pos.column+this.length+1,h=o.start.column-this.pos.column;if(this.updateAnchors(r),l&&(this.length+=c),l&&!this.session.$fromUndo){if(r.action==="insert")for(var d=this.others.length-1;d>=0;d--){var g=this.others[d],_={row:g.row,column:g.column+h};this.doc.insertMergedLines(_,r.lines)}else if(r.action==="remove")for(var d=this.others.length-1;d>=0;d--){var g=this.others[d],_={row:g.row,column:g.column+h};this.doc.remove(new B(_.row,_.column,_.row,_.column-c))}}this.$updating=!1,this.updateMarkers()}},a.prototype.updateAnchors=function(r){this.pos.onChange(r);for(var o=this.others.length;o--;)this.others[o].onChange(r);this.updateMarkers()},a.prototype.updateMarkers=function(){if(!this.$updating){var r=this,o=this.session,c=function(h,d){o.removeMarker(h.markerId),h.markerId=o.addMarker(new B(h.row,h.column,h.row,h.column+r.length),d,null,!1)};c(this.pos,this.mainClass);for(var l=this.others.length;l--;)c(this.others[l],this.othersClass)}},a.prototype.onCursorChange=function(r){if(!(this.$updating||!this.session)){var o=this.session.selection.getCursor();o.row===this.pos.row&&o.column>=this.pos.column&&o.column<=this.pos.column+this.length?(this.showOtherMarkers(),this._emit("cursorEnter",r)):(this.hideOtherMarkers(),this._emit("cursorLeave",r))}},a.prototype.detach=function(){this.session.removeMarker(this.pos&&this.pos.markerId),this.hideOtherMarkers(),this.doc.off("change",this.$onUpdate),this.session.selection.off("changeCursor",this.$onCursorChange),this.session.setUndoSelect(!0),this.session=null},a.prototype.cancel=function(){if(this.$undoStackDepth!==-1){for(var r=this.session.getUndoManager(),o=(r.$undoStack||r.$undostack).length-this.$undoStackDepth,c=0;c1?P.multiSelect.joinSelections():P.multiSelect.splitIntoLines()},bindKey:{win:"Ctrl-Alt-L",mac:"Ctrl-Alt-L"},readOnly:!0},{name:"splitSelectionIntoLines",description:"Split into lines",exec:function(P){P.multiSelect.splitIntoLines()},readOnly:!0},{name:"alignCursors",description:"Align cursors",exec:function(P){P.alignCursors()},bindKey:{win:"Ctrl-Alt-A",mac:"Ctrl-Alt-A"},scrollIntoView:"cursor"},{name:"findAll",description:"Find all",exec:function(P){P.findAll()},bindKey:{win:"Ctrl-Alt-K",mac:"Ctrl-Alt-G"},scrollIntoView:"cursor",readOnly:!0}],p.multiSelectCommands=[{name:"singleSelection",description:"Single selection",bindKey:"esc",exec:function(P){P.exitMultiSelectMode()},scrollIntoView:"cursor",readOnly:!0,isAvailable:function(P){return P&&P.inMultiSelectMode}}];var B=s("../keyboard/hash_handler").HashHandler;p.keyboardHandler=new B(p.multiSelectCommands)}),ace.define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor","ace/config"],function(s,p,m){var B=s("./range_list").RangeList,P=s("./range").Range,C=s("./selection").Selection,f=s("./mouse/multi_select_handler").onMouseDown,a=s("./lib/event"),r=s("./lib/lang"),o=s("./commands/multi_select_commands");p.commands=o.defaultCommands.concat(o.multiSelectCommands);var c=s("./search").Search,l=new c;function h(y,I,w){return l.$options.wrap=!0,l.$options.needle=I,l.$options.backwards=w==-1,l.find(y)}var d=s("./edit_session").EditSession;(function(){this.getSelectionMarkers=function(){return this.$selectionMarkers}}).call(d.prototype),function(){this.ranges=null,this.rangeList=null,this.addRange=function(y,I){if(y){if(!this.inMultiSelectMode&&this.rangeCount===0){var w=this.toOrientedRange();if(this.rangeList.add(w),this.rangeList.add(y),this.rangeList.ranges.length!=2)return this.rangeList.removeAll(),I||this.fromOrientedRange(y);this.rangeList.removeAll(),this.rangeList.add(w),this.$onAddRange(w)}y.cursor||(y.cursor=y.end);var x=this.rangeList.add(y);return this.$onAddRange(y),x.length&&this.$onRemoveRange(x),this.rangeCount>1&&!this.inMultiSelectMode&&(this._signal("multiSelect"),this.inMultiSelectMode=!0,this.session.$undoSelect=!1,this.rangeList.attach(this.session)),I||this.fromOrientedRange(y)}},this.toSingleRange=function(y){y=y||this.ranges[0];var I=this.rangeList.removeAll();I.length&&this.$onRemoveRange(I),y&&this.fromOrientedRange(y)},this.substractPoint=function(y){var I=this.rangeList.substractPoint(y);if(I)return this.$onRemoveRange(I),I[0]},this.mergeOverlappingRanges=function(){var y=this.rangeList.merge();y.length&&this.$onRemoveRange(y)},this.$onAddRange=function(y){this.rangeCount=this.rangeList.ranges.length,this.ranges.unshift(y),this._signal("addRange",{range:y})},this.$onRemoveRange=function(y){if(this.rangeCount=this.rangeList.ranges.length,this.rangeCount==1&&this.inMultiSelectMode){var I=this.rangeList.ranges.pop();y.push(I),this.rangeCount=0}for(var w=y.length;w--;){var x=this.ranges.indexOf(y[w]);this.ranges.splice(x,1)}this._signal("removeRange",{ranges:y}),this.rangeCount===0&&this.inMultiSelectMode&&(this.inMultiSelectMode=!1,this._signal("singleSelect"),this.session.$undoSelect=!0,this.rangeList.detach(this.session)),I=I||this.ranges[0],I&&!I.isEqual(this.getRange())&&this.fromOrientedRange(I)},this.$initRangeList=function(){this.rangeList||(this.rangeList=new B,this.ranges=[],this.rangeCount=0)},this.getAllRanges=function(){return this.rangeCount?this.rangeList.ranges.concat():[this.getRange()]},this.splitIntoLines=function(){for(var y=this.ranges.length?this.ranges:[this.getRange()],I=[],w=0;w1){var y=this.rangeList.ranges,I=y[y.length-1],w=P.fromPoints(y[0].start,I.end);this.toSingleRange(),this.setSelectionRange(w,I.cursor==I.start)}else{var x=this.session.documentToScreenPosition(this.cursor),N=this.session.documentToScreenPosition(this.anchor),D=this.rectangularRangeBlock(x,N);D.forEach(this.addRange,this)}},this.rectangularRangeBlock=function(y,I,w){var x=[],N=y.column0;)W--;if(W>0)for(var K=0;x[K].isEmpty();)K++;for(var Q=W;Q>=K;Q--)x[Q].isEmpty()&&x.splice(Q,1)}return x}}.call(C.prototype);var g=s("./editor").Editor;(function(){this.updateSelectionMarkers=function(){this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.addSelectionMarker=function(y){y.cursor||(y.cursor=y.end);var I=this.getSelectionStyle();return y.marker=this.session.addMarker(y,"ace_selection",I),this.session.$selectionMarkers.push(y),this.session.selectionMarkerCount=this.session.$selectionMarkers.length,y},this.removeSelectionMarker=function(y){if(y.marker){this.session.removeMarker(y.marker);var I=this.session.$selectionMarkers.indexOf(y);I!=-1&&this.session.$selectionMarkers.splice(I,1),this.session.selectionMarkerCount=this.session.$selectionMarkers.length}},this.removeSelectionMarkers=function(y){for(var I=this.session.$selectionMarkers,w=y.length;w--;){var x=y[w];if(x.marker){this.session.removeMarker(x.marker);var N=I.indexOf(x);N!=-1&&I.splice(N,1)}}this.session.selectionMarkerCount=I.length},this.$onAddRange=function(y){this.addSelectionMarker(y.range),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onRemoveRange=function(y){this.removeSelectionMarkers(y.ranges),this.renderer.updateCursor(),this.renderer.updateBackMarkers()},this.$onMultiSelect=function(y){this.inMultiSelectMode||(this.inMultiSelectMode=!0,this.setStyle("ace_multiselect"),this.keyBinding.addKeyboardHandler(o.keyboardHandler),this.commands.setDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers())},this.$onSingleSelect=function(y){this.session.multiSelect.inVirtualMode||(this.inMultiSelectMode=!1,this.unsetStyle("ace_multiselect"),this.keyBinding.removeKeyboardHandler(o.keyboardHandler),this.commands.removeDefaultHandler("exec",this.$onMultiSelectExec),this.renderer.updateCursor(),this.renderer.updateBackMarkers(),this._emit("changeSelection"))},this.$onMultiSelectExec=function(y){var I=y.command,w=y.editor;if(w.multiSelect){if(I.multiSelectAction)I.multiSelectAction=="forEach"?x=w.forEachSelection(I,y.args):I.multiSelectAction=="forEachLine"?x=w.forEachSelection(I,y.args,!0):I.multiSelectAction=="single"?(w.exitMultiSelectMode(),x=I.exec(w,y.args||{})):x=I.multiSelectAction(w,y.args||{});else{var x=I.exec(w,y.args||{});w.multiSelect.addRange(w.multiSelect.toOrientedRange()),w.multiSelect.mergeOverlappingRanges()}return x}},this.forEachSelection=function(y,I,w){if(!this.inVirtualSelectionMode){var x=w&&w.keepOrder,N=w==!0||w&&w.$byLines,D=this.session,R=this.selection,S=R.rangeList,F=(x?R:S).ranges,A;if(!F.length)return y.exec?y.exec(this,I||{}):y(this,I||{});var E=R._eventRegistry;R._eventRegistry={};var O=new C(D);this.inVirtualSelectionMode=!0;for(var k=F.length;k--;){if(N)for(;k>0&&F[k].start.row==F[k-1].end.row;)k--;O.fromOrientedRange(F[k]),O.index=k,this.selection=D.selection=O;var H=y.exec?y.exec(this,I||{}):y(this,I||{});!A&&H!==void 0&&(A=H),O.toOrientedRange(F[k])}O.detach(),this.selection=D.selection=R,this.inVirtualSelectionMode=!1,R._eventRegistry=E,R.mergeOverlappingRanges(),R.ranges[0]&&R.fromOrientedRange(R.ranges[0]);var V=this.renderer.$scrollAnimation;return this.onCursorChange(),this.onSelectionChange(),V&&V.from==V.to&&this.renderer.animateScrolling(V.from),A}},this.exitMultiSelectMode=function(){!this.inMultiSelectMode||this.inVirtualSelectionMode||this.multiSelect.toSingleRange()},this.getSelectedText=function(){var y="";if(this.inMultiSelectMode&&!this.inVirtualSelectionMode){for(var I=this.multiSelect.rangeList.ranges,w=[],x=0;x0);R<0&&(R=0),S>=A&&(S=A-1)}var O=this.session.removeFullLines(R,S);O=this.$reAlignText(O,F),this.session.insert({row:R,column:0},O.join(` `)+` -`),F||(D.start.column=0,D.end.column=L[L.length-1].length),this.selection.setRange(D)}else{N.forEach(function(W){S.substractPoint(W.cursor)});var O=0,H=1/0,V=b.map(function(W){var K=W.cursor,Q=I.getLine(K.row),ie=Q.substr(K.column).search(/\S/g);return ie==-1&&(ie=0),K.column>O&&(O=K.column),ieJ?I.insert(Q,s.stringRepeat(" ",ie-J)):I.remove(new P(Q.row,Q.column,Q.row,Q.column-ie+J)),W.start.column=W.end.column=O,W.start.row=W.end.row=Q.row,W.cursor=W.end}),S.fromOrientedRange(b[0]),this.renderer.updateCursor(),this.renderer.updateBackMarkers()}},this.$reAlignText=function(I,S){var b=!0,x=!0,N,D,R;return I.map(function(L){var O=L.match(/(\s*)(.*?)(\s*)([=:].*)/);return O?N==null?(N=O[1].length,D=O[2].length,R=O[3].length,O):(N+D+R!=O[1].length+O[2].length+O[3].length&&(x=!1),N!=O[1].length&&(b=!1),N>O[1].length&&(N=O[1].length),DO[3].length&&(R=O[3].length),O):[L]}).map(S?F:b?x?A:F:T);function w(L){return s.stringRepeat(" ",L)}function F(L){return L[2]?w(N)+L[2]+w(D-L[2].length+R)+L[4].replace(/^([=:])\s+/,"$1 "):L[0]}function A(L){return L[2]?w(N+D-L[2].length)+L[2]+w(R)+L[4].replace(/^([=:])\s+/,"$1 "):L[0]}function T(L){return L[2]?w(N)+L[2]+w(R)+L[4].replace(/^([=:])\s+/,"$1 "):L[0]}}}).call(g.prototype);function _(I,S){return I.row==S.row&&I.column==S.column}p.onSessionChange=function(I){var S=I.session;S&&!S.multiSelect&&(S.$selectionMarkers=[],S.selection.$initRangeList(),S.multiSelect=S.selection),this.multiSelect=S&&S.multiSelect;var b=I.oldSession;b&&(b.multiSelect.off("addRange",this.$onAddRange),b.multiSelect.off("removeRange",this.$onRemoveRange),b.multiSelect.off("multiSelect",this.$onMultiSelect),b.multiSelect.off("singleSelect",this.$onSingleSelect),b.multiSelect.lead.off("change",this.$checkMultiselectChange),b.multiSelect.anchor.off("change",this.$checkMultiselectChange)),S&&(S.multiSelect.on("addRange",this.$onAddRange),S.multiSelect.on("removeRange",this.$onRemoveRange),S.multiSelect.on("multiSelect",this.$onMultiSelect),S.multiSelect.on("singleSelect",this.$onSingleSelect),S.multiSelect.lead.on("change",this.$checkMultiselectChange),S.multiSelect.anchor.on("change",this.$checkMultiselectChange)),S&&this.inMultiSelectMode!=S.selection.inMultiSelectMode&&(S.selection.inMultiSelectMode?this.$onMultiSelect():this.$onSingleSelect())};function v(I){I.$multiselectOnSessionChange||(I.$onAddRange=I.$onAddRange.bind(I),I.$onRemoveRange=I.$onRemoveRange.bind(I),I.$onMultiSelect=I.$onMultiSelect.bind(I),I.$onSingleSelect=I.$onSingleSelect.bind(I),I.$multiselectOnSessionChange=p.onSessionChange.bind(I),I.$checkMultiselectChange=I.$checkMultiselectChange.bind(I),I.$multiselectOnSessionChange(I),I.on("changeSession",I.$multiselectOnSessionChange),I.on("mousedown",f),I.commands.addCommands(o.defaultCommands),k(I))}function k(I){if(!I.textInput)return;var S=I.textInput.getElement(),b=!1;a.addListener(S,"keydown",function(N){var D=N.keyCode==18&&!(N.ctrlKey||N.shiftKey||N.metaKey);I.$blockSelectEnabled&&D?b||(I.renderer.setMouseCursor("crosshair"),b=!0):b&&x()},I),a.addListener(S,"keyup",x,I),a.addListener(S,"blur",x,I);function x(N){b&&(I.renderer.setMouseCursor(""),b=!1)}}p.MultiSelect=v,r("./config").defineOptions(g.prototype,"editor",{enableMultiselect:{set:function(I){v(this),I?this.on("mousedown",f):this.off("mousedown",f)},value:!0},enableBlockSelect:{set:function(I){this.$blockSelectEnabled=I},value:!0}})}),ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"],function(r,p,m){var B=r("../../range").Range,P=p.FoldMode=function(){};(function(){this.foldingStartMarker=null,this.foldingStopMarker=null,this.getFoldWidget=function(C,f,a){var s=C.getLine(a);return this.foldingStartMarker.test(s)?"start":f=="markbeginend"&&this.foldingStopMarker&&this.foldingStopMarker.test(s)?"end":""},this.getFoldWidgetRange=function(C,f,a){return null},this.indentationBlock=function(C,f,a){var s=/\S/,o=C.getLine(f),c=o.search(s);if(c!=-1){for(var l=a||o.length,h=C.getLength(),d=f,g=f;++fd){var k=C.getLine(g).length;return new B(d,l,g,k)}}},this.openingBracketBlock=function(C,f,a,s,o){var c={row:a,column:s+1},l=C.$findClosingBracket(f,c,o);if(l){var h=C.foldWidgets[l.row];return h==null&&(h=C.getFoldWidget(l.row)),h=="start"&&l.row>c.row&&(l.row--,l.column=C.getLine(l.row).length),B.fromPoints(c,l)}},this.closingBracketBlock=function(C,f,a,s,o){var c={row:a,column:s},l=C.$findOpeningBracket(f,c);if(l)return l.column++,c.column--,B.fromPoints(l,c)}}).call(P.prototype)}),ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range","ace/config"],function(r,p,m){var B=r("../line_widgets").LineWidgets,P=r("../lib/dom"),C=r("../range").Range,f=r("../config").nls;function a(o,c,l){for(var h=0,d=o.length-1;h<=d;){var g=h+d>>1,_=l(c,o[g]);if(_>0)h=g+1;else if(_<0)d=g-1;else return g}return-(h+1)}function s(o,c,l){var h=o.getAnnotations().sort(C.comparePoints);if(h.length){var d=a(h,{row:c,column:-1},C.comparePoints);d<0&&(d=-d-1),d>=h.length?d=l>0?0:h.length-1:d===0&&l<0&&(d=h.length-1);var g=h[d];if(!(!g||!l)){if(g.row===c){do g=h[d+=l];while(g&&g.row===c);if(!g)return h.slice()}var _=[];c=g.row;do _[l<0?"unshift":"push"](g),g=h[d+=l];while(g&&g.row==c);return _.length&&_}}}p.showErrorMarker=function(o,c){var l=o.session;l.widgetManager||(l.widgetManager=new B(l),l.widgetManager.attach(o));var h=o.getCursorPosition(),d=h.row,g=l.widgetManager.getWidgetsAtRow(d).filter(function(D){return D.type=="errorMarker"})[0];g?g.destroy():d-=c;var _=s(l,d,c),v;if(_){var k=_[0];h.column=(k.pos&&typeof k.column!="number"?k.pos.sc:k.column)||0,h.row=k.row,v=o.renderer.$gutterLayer.$annotations[h.row]}else{if(g)return;v={text:[f("Looks good!")],className:"ace_ok"}}o.session.unfold(h.row),o.selection.moveToPosition(h);var I={row:h.row,fixedWidth:!0,coverGutter:!0,el:P.createElement("div"),type:"errorMarker"},S=I.el.appendChild(P.createElement("div")),b=I.el.appendChild(P.createElement("div"));b.className="error_widget_arrow "+v.className;var x=o.renderer.$cursorLayer.getPixelPosition(h).left;b.style.left=x+o.renderer.gutterWidth-5+"px",I.el.className="error_widget_wrapper",S.className="error_widget "+v.className,S.innerHTML=v.text.join("
"),S.appendChild(P.createElement("div"));var N=function(D,R,w){if(R===0&&(w==="esc"||w==="return"))return I.destroy(),{command:"null"}};I.destroy=function(){o.$mouseHandler.isMousePressed||(o.keyBinding.removeKeyboardHandler(N),l.widgetManager.removeLineWidget(I),o.off("changeSelection",I.destroy),o.off("changeSession",I.destroy),o.off("mouseup",I.destroy),o.off("change",I.destroy))},o.keyBinding.addKeyboardHandler(N),o.on("changeSelection",I.destroy),o.on("changeSession",I.destroy),o.on("mouseup",I.destroy),o.on("change",I.destroy),o.session.widgetManager.addLineWidget(I),I.el.onmousedown=o.focus.bind(o),o.renderer.scrollCursorIntoView(null,.5,{bottom:I.el.offsetHeight})},P.importCssString(` +`),F||(D.start.column=0,D.end.column=O[O.length-1].length),this.selection.setRange(D)}else{N.forEach(function(W){I.substractPoint(W.cursor)});var k=0,H=1/0,V=w.map(function(W){var K=W.cursor,Q=y.getLine(K.row),ie=Q.substr(K.column).search(/\S/g);return ie==-1&&(ie=0),K.column>k&&(k=K.column),ieJ?y.insert(Q,r.stringRepeat(" ",ie-J)):y.remove(new P(Q.row,Q.column,Q.row,Q.column-ie+J)),W.start.column=W.end.column=k,W.start.row=W.end.row=Q.row,W.cursor=W.end}),I.fromOrientedRange(w[0]),this.renderer.updateCursor(),this.renderer.updateBackMarkers()}},this.$reAlignText=function(y,I){var w=!0,x=!0,N,D,R;return y.map(function(O){var k=O.match(/(\s*)(.*?)(\s*)([=:].*)/);return k?N==null?(N=k[1].length,D=k[2].length,R=k[3].length,k):(N+D+R!=k[1].length+k[2].length+k[3].length&&(x=!1),N!=k[1].length&&(w=!1),N>k[1].length&&(N=k[1].length),Dk[3].length&&(R=k[3].length),k):[O]}).map(I?F:w?x?A:F:E);function S(O){return r.stringRepeat(" ",O)}function F(O){return O[2]?S(N)+O[2]+S(D-O[2].length+R)+O[4].replace(/^([=:])\s+/,"$1 "):O[0]}function A(O){return O[2]?S(N+D-O[2].length)+O[2]+S(R)+O[4].replace(/^([=:])\s+/,"$1 "):O[0]}function E(O){return O[2]?S(N)+O[2]+S(R)+O[4].replace(/^([=:])\s+/,"$1 "):O[0]}}}).call(g.prototype);function _(y,I){return y.row==I.row&&y.column==I.column}p.onSessionChange=function(y){var I=y.session;I&&!I.multiSelect&&(I.$selectionMarkers=[],I.selection.$initRangeList(),I.multiSelect=I.selection),this.multiSelect=I&&I.multiSelect;var w=y.oldSession;w&&(w.multiSelect.off("addRange",this.$onAddRange),w.multiSelect.off("removeRange",this.$onRemoveRange),w.multiSelect.off("multiSelect",this.$onMultiSelect),w.multiSelect.off("singleSelect",this.$onSingleSelect),w.multiSelect.lead.off("change",this.$checkMultiselectChange),w.multiSelect.anchor.off("change",this.$checkMultiselectChange)),I&&(I.multiSelect.on("addRange",this.$onAddRange),I.multiSelect.on("removeRange",this.$onRemoveRange),I.multiSelect.on("multiSelect",this.$onMultiSelect),I.multiSelect.on("singleSelect",this.$onSingleSelect),I.multiSelect.lead.on("change",this.$checkMultiselectChange),I.multiSelect.anchor.on("change",this.$checkMultiselectChange)),I&&this.inMultiSelectMode!=I.selection.inMultiSelectMode&&(I.selection.inMultiSelectMode?this.$onMultiSelect():this.$onSingleSelect())};function v(y){y.$multiselectOnSessionChange||(y.$onAddRange=y.$onAddRange.bind(y),y.$onRemoveRange=y.$onRemoveRange.bind(y),y.$onMultiSelect=y.$onMultiSelect.bind(y),y.$onSingleSelect=y.$onSingleSelect.bind(y),y.$multiselectOnSessionChange=p.onSessionChange.bind(y),y.$checkMultiselectChange=y.$checkMultiselectChange.bind(y),y.$multiselectOnSessionChange(y),y.on("changeSession",y.$multiselectOnSessionChange),y.on("mousedown",f),y.commands.addCommands(o.defaultCommands),M(y))}function M(y){if(!y.textInput)return;var I=y.textInput.getElement(),w=!1;a.addListener(I,"keydown",function(N){var D=N.keyCode==18&&!(N.ctrlKey||N.shiftKey||N.metaKey);y.$blockSelectEnabled&&D?w||(y.renderer.setMouseCursor("crosshair"),w=!0):w&&x()},y),a.addListener(I,"keyup",x,y),a.addListener(I,"blur",x,y);function x(N){w&&(y.renderer.setMouseCursor(""),w=!1)}}p.MultiSelect=v,s("./config").defineOptions(g.prototype,"editor",{enableMultiselect:{set:function(y){v(this),y?this.on("mousedown",f):this.off("mousedown",f)},value:!0},enableBlockSelect:{set:function(y){this.$blockSelectEnabled=y},value:!0}})}),ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"],function(s,p,m){var B=s("../../range").Range,P=p.FoldMode=function(){};(function(){this.foldingStartMarker=null,this.foldingStopMarker=null,this.getFoldWidget=function(C,f,a){var r=C.getLine(a);return this.foldingStartMarker.test(r)?"start":f=="markbeginend"&&this.foldingStopMarker&&this.foldingStopMarker.test(r)?"end":""},this.getFoldWidgetRange=function(C,f,a){return null},this.indentationBlock=function(C,f,a){var r=/\S/,o=C.getLine(f),c=o.search(r);if(c!=-1){for(var l=a||o.length,h=C.getLength(),d=f,g=f;++fd){var M=C.getLine(g).length;return new B(d,l,g,M)}}},this.openingBracketBlock=function(C,f,a,r,o){var c={row:a,column:r+1},l=C.$findClosingBracket(f,c,o);if(l){var h=C.foldWidgets[l.row];return h==null&&(h=C.getFoldWidget(l.row)),h=="start"&&l.row>c.row&&(l.row--,l.column=C.getLine(l.row).length),B.fromPoints(c,l)}},this.closingBracketBlock=function(C,f,a,r,o){var c={row:a,column:r},l=C.$findOpeningBracket(f,c);if(l)return l.column++,c.column--,B.fromPoints(l,c)}}).call(P.prototype)}),ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range","ace/config"],function(s,p,m){var B=s("../line_widgets").LineWidgets,P=s("../lib/dom"),C=s("../range").Range,f=s("../config").nls;function a(o,c,l){for(var h=0,d=o.length-1;h<=d;){var g=h+d>>1,_=l(c,o[g]);if(_>0)h=g+1;else if(_<0)d=g-1;else return g}return-(h+1)}function r(o,c,l){var h=o.getAnnotations().sort(C.comparePoints);if(h.length){var d=a(h,{row:c,column:-1},C.comparePoints);d<0&&(d=-d-1),d>=h.length?d=l>0?0:h.length-1:d===0&&l<0&&(d=h.length-1);var g=h[d];if(!(!g||!l)){if(g.row===c){do g=h[d+=l];while(g&&g.row===c);if(!g)return h.slice()}var _=[];c=g.row;do _[l<0?"unshift":"push"](g),g=h[d+=l];while(g&&g.row==c);return _.length&&_}}}p.showErrorMarker=function(o,c){var l=o.session;l.widgetManager||(l.widgetManager=new B(l),l.widgetManager.attach(o));var h=o.getCursorPosition(),d=h.row,g=l.widgetManager.getWidgetsAtRow(d).filter(function(D){return D.type=="errorMarker"})[0];g?g.destroy():d-=c;var _=r(l,d,c),v;if(_){var M=_[0];h.column=(M.pos&&typeof M.column!="number"?M.pos.sc:M.column)||0,h.row=M.row,v=o.renderer.$gutterLayer.$annotations[h.row]}else{if(g)return;v={text:[f("Looks good!")],className:"ace_ok"}}o.session.unfold(h.row),o.selection.moveToPosition(h);var y={row:h.row,fixedWidth:!0,coverGutter:!0,el:P.createElement("div"),type:"errorMarker"},I=y.el.appendChild(P.createElement("div")),w=y.el.appendChild(P.createElement("div"));w.className="error_widget_arrow "+v.className;var x=o.renderer.$cursorLayer.getPixelPosition(h).left;w.style.left=x+o.renderer.gutterWidth-5+"px",y.el.className="error_widget_wrapper",I.className="error_widget "+v.className,I.innerHTML=v.text.join("
"),I.appendChild(P.createElement("div"));var N=function(D,R,S){if(R===0&&(S==="esc"||S==="return"))return y.destroy(),{command:"null"}};y.destroy=function(){o.$mouseHandler.isMousePressed||(o.keyBinding.removeKeyboardHandler(N),l.widgetManager.removeLineWidget(y),o.off("changeSelection",y.destroy),o.off("changeSession",y.destroy),o.off("mouseup",y.destroy),o.off("change",y.destroy))},o.keyBinding.addKeyboardHandler(N),o.on("changeSelection",y.destroy),o.on("changeSession",y.destroy),o.on("mouseup",y.destroy),o.on("change",y.destroy),o.session.widgetManager.addLineWidget(y),y.el.onmousedown=o.focus.bind(o),o.renderer.scrollCursorIntoView(null,.5,{bottom:y.el.offsetHeight})},P.importCssString(` .error_widget_wrapper { background: inherit; color: inherit; @@ -2008,26 +2008,27 @@ function ${m.javascriptGenerator.FUNCTION_NAME_PLACEHOLDER_}(haystack, needle, r border-left-color: transparent!important; top: -5px; } -`,"error_marker.css",!1)}),ace.define("ace/ace",["require","exports","module","ace/lib/dom","ace/range","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config","ace/loader_build"],function(r,p,m){r("./loader_build")(p);var B=r("./lib/dom"),P=r("./range").Range,C=r("./editor").Editor,f=r("./edit_session").EditSession,a=r("./undomanager").UndoManager,s=r("./virtual_renderer").VirtualRenderer;r("./worker/worker_client"),r("./keyboard/hash_handler"),r("./placeholder"),r("./multi_select"),r("./mode/folding/fold_mode"),r("./theme/textmate"),r("./ext/error_marker"),p.config=r("./config"),p.edit=function(o,c){if(typeof o=="string"){var l=o;if(o=document.getElementById(l),!o)throw new Error("ace.edit can't find div #"+l)}if(o&&o.env&&o.env.editor instanceof C)return o.env.editor;var h="";if(o&&/input|textarea/i.test(o.tagName)){var d=o;h=d.value,o=B.createElement("pre"),d.parentNode.replaceChild(o,d)}else o&&(h=o.textContent,o.innerHTML="");var g=p.createEditSession(h),_=new C(new s(o),g,c),v={document:g,editor:_,onResize:_.resize.bind(_,null)};return d&&(v.textarea=d),_.on("destroy",function(){v.editor.container.env=null}),_.container.env=_.env=v,_},p.createEditSession=function(o,c){var l=new f(o,c);return l.setUndoManager(new a),l},p.Range=P,p.Editor=C,p.EditSession=f,p.UndoManager=a,p.VirtualRenderer=s,p.version=p.config.version}),function(){ace.require(["ace/ace"],function(r){r&&(r.config.init(!0),r.define=ace.define),window.ace||(window.ace=r);for(var p in r)r.hasOwnProperty(p)&&(window.ace[p]=r[p]);window.ace.default=window.ace,y&&(y.exports=window.ace)})}()})(Sm);var V_=Sm.exports;const Im=Tm(V_),et=Im.edit("aceCode",{fontSize:16,mode:"ace/mode/java"}),_u=100;var $l="",Ur="",Hr={},vl=[],Rm=[];function W_(y){$l+=y}function Cm(){vl=[],$l="",Ur="",Hr={},Rm.forEach(y=>{et.session.removeMarker(y)})}function As(y,$,r,p){(p??0${y} error occured on line ${m[0]}: ${$} - (highlighting index ${r} to ${p})`,gl($,r,p)}function km(y){for(var $ in Hr){var r=y.getBlockById($);r.setWarningText(Hr[$])}}function ni(y,$){As("runtime",y,$.startIndex,$.endIndex),Hr[$.blockID]=y,console.log("here are the block errors"),console.log(Hr)}function gl(y,$,r){var p=Am($,r),m={row:p[0]-1,column:p[1],text:y,type:"error"};vl.push(m),z_(p[0],p[1],p[2],p[3])}function z_(y,$,r,p){console.error(`startRow: ${y} , start column: ${$} -edRow: ${r}, endcolumn: ${p}`);var m=et.session,B=Im.require("ace/range").Range,P=new B(y-1,$,r-1,p),C=m.addMarker(P,"error-marker","text"),f=` +`,"error_marker.css",!1)}),ace.define("ace/ace",["require","exports","module","ace/lib/dom","ace/range","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config","ace/loader_build"],function(s,p,m){s("./loader_build")(p);var B=s("./lib/dom"),P=s("./range").Range,C=s("./editor").Editor,f=s("./edit_session").EditSession,a=s("./undomanager").UndoManager,r=s("./virtual_renderer").VirtualRenderer;s("./worker/worker_client"),s("./keyboard/hash_handler"),s("./placeholder"),s("./multi_select"),s("./mode/folding/fold_mode"),s("./theme/textmate"),s("./ext/error_marker"),p.config=s("./config"),p.edit=function(o,c){if(typeof o=="string"){var l=o;if(o=document.getElementById(l),!o)throw new Error("ace.edit can't find div #"+l)}if(o&&o.env&&o.env.editor instanceof C)return o.env.editor;var h="";if(o&&/input|textarea/i.test(o.tagName)){var d=o;h=d.value,o=B.createElement("pre"),d.parentNode.replaceChild(o,d)}else o&&(h=o.textContent,o.innerHTML="");var g=p.createEditSession(h),_=new C(new r(o),g,c),v={document:g,editor:_,onResize:_.resize.bind(_,null)};return d&&(v.textarea=d),_.on("destroy",function(){v.editor.container.env=null}),_.container.env=_.env=v,_},p.createEditSession=function(o,c){var l=new f(o,c);return l.setUndoManager(new a),l},p.Range=P,p.Editor=C,p.EditSession=f,p.UndoManager=a,p.VirtualRenderer=r,p.version=p.config.version}),function(){ace.require(["ace/ace"],function(s){s&&(s.config.init(!0),s.define=ace.define),window.ace||(window.ace=s);for(var p in s)s.hasOwnProperty(p)&&(window.ace[p]=s[p]);window.ace.default=window.ace,T&&(T.exports=window.ace)})}()})(wm);var V_=wm.exports;const Sm=vm(V_),et=Sm.edit("aceCode",{fontSize:16,mode:"ace/mode/java"}),_u=100;var $l="",Ur="",Hr={},vl=[],Im=[];function W_(T){$l+=T}function Rm(){vl=[],$l="",Ur="",Hr={},Im.forEach(T=>{et.session.removeMarker(T)})}function gn(T,$,s,p){(p??0${T} error occured on line ${m[0]}: ${$} + (highlighting index ${s} to ${p})`,gl($,s,p)}function Cm(T){for(var $ in Hr){var s=T.getBlockById($);s.setWarningText(Hr[$])}}function Xt(T,$){gn("runtime",T,$.startIndex,$.endIndex),Hr[$.blockID]=T,console.log("here are the block errors"),console.log(Hr)}function gl(T,$,s){var p=Am($,s),m={row:p[0]-1,column:p[1],text:T,type:"error"};vl.push(m),z_(p[0],p[1],p[2],p[3])}function z_(T,$,s,p){console.error(`startRow: ${T} , start column: ${$} +edRow: ${s}, endcolumn: ${p}`);var m=et.session,B=Sm.require("ace/range").Range,P=new B(T-1,$,s-1,p),C=m.addMarker(P,"error-marker","text"),f=` .error-marker { position: absolute; z-index: 1; background-color: rgba(255, 0, 0, 0.2); border-bottom: 2px solid red; } - `,a=document.getElementById("custom-style");return a||(console.error("couldn't find the stylesheet"),a=document.createElement("style"),a.setAttribute("id","custom-style"),document.head.appendChild(a)),a.appendChild(document.createTextNode(f)),console.log("attempted to highlight"),Rm.push(C),C}const Am=(y,$)=>{let r=et==null?void 0:et.getValue();console.log(`the length is ${r.length} and the endIndex is ${$}`);var p=0,m=0,B=0,P=0,C=0,f=0;for(let o=0;o{let y=et==null?void 0:et.getValue();console.log(y);let $=new K_(y),r=$==null?void 0:$.lex();console.log(r);let p=new j_(r),m=p==null?void 0:p.parse();return console.log(m),m};class Y_{constructor($,r,p,m){this.token_type=$,this.value=r,this.startIndex=p,this.endIndex=m}}class K_{constructor($){var r;($==null?void 0:$.length)>0&&$[($==null?void 0:$.length)-1]!==` + `,a=document.getElementById("custom-style");return a||(console.error("couldn't find the stylesheet"),a=document.createElement("style"),a.setAttribute("id","custom-style"),document.head.appendChild(a)),a.appendChild(document.createTextNode(f)),console.log("attempted to highlight"),Im.push(C),C}const Am=(T,$)=>{let s=et==null?void 0:et.getValue();console.log(`the length is ${s.length} and the endIndex is ${$}`);var p=0,m=0,B=0,P=0,C=0,f=0;for(let o=0;o{let T=et==null?void 0:et.getValue();console.log(T);let $=new K_(T),s=$==null?void 0:$.lex();console.log(s);let p=new j_(s),m=p==null?void 0:p.parse();return console.log(m),m};class Y_{constructor($,s,p,m){this.token_type=$,this.value=s,this.startIndex=p,this.endIndex=m}}class K_{constructor($){var s;($==null?void 0:$.length)>0&&$[($==null?void 0:$.length)-1]!==` `&&($+=` -`),this.source=$,this.tokens=[],this.i=0,this.length=(r=this.source)==null?void 0:r.length,this.token_so_far="",this.keywords=["if","else","end","print","for","while","and","or","do","repeat","until","not","return"],this.types=["int","double","String","char","float","boolean","short","void","int[]"],this.startToken=0,this.currentLine=0}printTokens(){for(let $ of this.tokens)console.log(`Token: ${$.token_type}, Value: ${$.value}`)}has_letter(){const $=this.source[this.i];return/^[A-Za-z]$/.test($)}has($){return this.i"))this.capture(),this.has("=")?(this.capture(),this.emit_token("Greater_Than_Equal_To")):this.emit_token("Greater_Than");else if(this.has_digit()){for(;this.i"))this.capture(),this.has("=")?(this.capture(),this.emit_token("Greater_Than_Equal_To")):this.emit_token("Greater_Than");else if(this.has_digit()){for(;this.i{var S,b,x,N,D,R,w,F;switch($==null?void 0:$.type){case"COMMENT":var k=y.newBlock("praxly_comment_block");k.setFieldValue($.value,"COMMENT");break;case"SINGLE_LINE_COMMENT":var k=y.newBlock("praxly_single_line_comment_block");k.setFieldValue($.value,"COMMENT");break;case"INT":var k=y.newBlock("praxly_literal_block");k.setFieldValue($.value,"LITERAL");break;case"BOOLEAN":var k=0;$.value==="true"&&(k=y.newBlock("praxly_true_block")),$.value==="false"&&(k=y.newBlock("praxly_false_block"));break;case"STRING":var k=y.newBlock("praxly_literal_block");k.setFieldValue('"'+$.value+'"',"LITERAL");break;case"DOUBLE":case"CHAR":var k=y.newBlock("praxly_literal_block");k.setFieldValue($.value,"LITERAL");break;case"ADD":case"SUBTRACT":case"MULTIPLY":case"DIVIDE":case"EXPONENT":case"MOD":var k=y.newBlock("praxly_arithmetic_block"),r=Ze(y,$==null?void 0:$.left),p=Ze(y,$==null?void 0:$.right);k.setFieldValue($.type,"OPERATOR"),k.getInput("A_OPERAND").connection.connect(r==null?void 0:r.outputConnection),k.getInput("B_OPERAND").connection.connect(p==null?void 0:p.outputConnection);break;case"AND":case"OR":var k=y.newBlock("praxly_boolean_operators_block"),r=Ze(y,$==null?void 0:$.left),p=Ze(y,$==null?void 0:$.right);k.setFieldValue($.type,"OPERATOR"),k.getInput("A_OPERAND").connection.connect(r==null?void 0:r.outputConnection),k.getInput("B_OPERAND").connection.connect(p==null?void 0:p.outputConnection);break;case"EQUALS":case"LESS_THAN_EQUAL":case"GREATER_THAN_EQUAL":case"GREATER_THAN":case"LESS_THAN":case"NOT_EQUAL":var k=y.newBlock("praxly_compare_block"),r=Ze(y,$==null?void 0:$.left),p=Ze(y,$==null?void 0:$.right);k.getInput("A_OPERAND").connection.connect(r==null?void 0:r.outputConnection),k.getInput("B_OPERAND").connection.connect(p==null?void 0:p.outputConnection),k.setFieldValue($.type,"OPERATOR");break;case"PRINT":var k=y.newBlock("praxly_print_block"),I=Ze(y,$==null?void 0:$.value);k.getInput("EXPRESSION").connection.connect(I==null?void 0:I.outputConnection);break;case"CODEBLOCK":var m=$.statements.map(A=>{try{return Ze(y,A)}catch(T){return console.error("An error occurred: empty statement",T),null}});return J_(m),m;case"PROGRAM":return Ze(y,$.value);case"STATEMENT":var k=y.newBlock("praxly_statement_block"),I=Ze(y,$==null?void 0:$.value);k.getInput("EXPRESSION").connection.connect(I==null?void 0:I.outputConnection);break;case"IF":var k=y.newBlock("praxly_if_block"),C=Ze(y,$==null?void 0:$.condition),f=Ze(y,$==null?void 0:$.statement);k.getInput("CONDITION").connection.connect(C==null?void 0:C.outputConnection),k.getInput("STATEMENT").connection.connect((S=f[0])==null?void 0:S.previousConnection);break;case"IF_ELSE":var k=y.newBlock("praxly_if_else_block"),C=Ze(y,$==null?void 0:$.condition),m=Ze(y,$==null?void 0:$.statement),B=Ze(y,$==null?void 0:$.alternative);k.getInput("CONDITION").connection.connect(C==null?void 0:C.outputConnection),k.getInput("STATEMENT").connection.connect((b=m[0])==null?void 0:b.previousConnection),k.getInput("ALTERNATIVE").connection.connect((x=B[0])==null?void 0:x.previousConnection);break;case"VARIABLE":var k=y.newBlock("praxly_variable_block");k.setFieldValue($.name,"LITERAL");break;case"ASSIGNMENT":var P=Ze(y,$==null?void 0:$.value);if($.varType==="reassignment")var k=y.newBlock("praxly_reassignment_block");else{var k=y.newBlock("praxly_assignment_block");$.varType==="Praxly_array"?(k.dispose(),k=y.newBlock("praxly_array_assignment_block"),k.setFieldValue("int[]","VARTYPE")):k.setFieldValue($.varType.substring(7),"VARTYPE")}k.setFieldValue($.name,"VARIABLENAME"),k.getInput("EXPRESSION").connection.connect(P==null?void 0:P.outputConnection);break;case"WHILE":var k=y.newBlock("praxly_while_loop_block"),C=Ze(y,$==null?void 0:$.condition),f=Ze(y,$==null?void 0:$.statement);k.getInput("CONDITION").connection.connect(C==null?void 0:C.outputConnection),k.getInput("STATEMENT").connection.connect((N=f[0])==null?void 0:N.previousConnection);break;case"DO_WHILE":var k=y.newBlock("praxly_do_while_loop_block"),C=Ze(y,$==null?void 0:$.condition),f=Ze(y,$==null?void 0:$.statement);k.getInput("CONDITION").connection.connect(C==null?void 0:C.outputConnection),k.getInput("STATEMENT").connection.connect((D=f[0])==null?void 0:D.previousConnection);break;case"REPEAT_UNTIL":var k=y.newBlock("praxly_repeat_until_loop_block"),C=Ze(y,$==null?void 0:$.condition),f=Ze(y,$==null?void 0:$.statement);k.getInput("CONDITION").connection.connect(C==null?void 0:C.outputConnection),k.getInput("STATEMENT").connection.connect((R=f[0])==null?void 0:R.previousConnection);break;case"NOT":var k=y.newBlock("praxly_not_block"),I=Ze(y,$==null?void 0:$.value);k.getInput("EXPRESSION").connection.connect(I==null?void 0:I.outputConnection);break;case"RETURN":var k=y.newBlock("praxly_return_block"),I=Ze(y,$==null?void 0:$.value);k.getInput("EXPRESSION").connection.connect(I==null?void 0:I.outputConnection);break;case"FUNCTION_CALL":var k=y.newBlock("praxly_function_call_block"),v=y.newBlock("praxly_parameter_block");k.setFieldValue($==null?void 0:$.name,"PROCEDURE_NAME"),k.getInput("PARAMS").connection.connect(v==null?void 0:v.outputConnection);for(var _=$==null?void 0:$.params,a=0;a<((_==null?void 0:_.length)??0);a++){v.appendValueInput(`PARAM_${a}`);var s=Ze(y,_[a]);v.getInput(`PARAM_${a}`).connection.connect(s==null?void 0:s.outputConnection)}v.initSvg();break;case"FUNCTION_ASSIGNMENT":var o=$==null?void 0:$.returnType,_=$==null?void 0:$.params,k=y.newBlock("praxly_procedure_block"),v=y.newBlock("praxly_parameter_block");k.setFieldValue(o,"RETURNTYPE"),k.setFieldValue($==null?void 0:$.name,"PROCEDURE_NAME"),k.setFieldValue($==null?void 0:$.name,"END_PROCEDURE_NAME"),k.getInput("PARAMS").connection.connect(v==null?void 0:v.outputConnection);var c=Ze(y,$==null?void 0:$.contents);k.getInput("CONTENTS").connection.connect((w=c[0])==null?void 0:w.previousConnection);for(var a=0;a<((_==null?void 0:_.length)??0);a++){v.appendValueInput(`PARAM_${a}`);var l=y.newBlock("praxly_singular_param_block");l.setFieldValue(_[a][0],"VARTYPE"),l.setFieldValue(_[a][1],"VARIABLENAME"),v.getInput(`PARAM_${a}`).connection.connect(l==null?void 0:l.outputConnection),l.initSvg()}v.initSvg();break;case"FOR":var k=y.newBlock("praxly_for_loop_block");try{var h=y.newBlock("praxly_assignment_expression_block"),d=y.newBlock("praxly_reassignment_expression_block"),P=Ze(y,$==null?void 0:$.initialization.value);h.setFieldValue($==null?void 0:$.initialization.varType.substring(7),"VARTYPE"),h.setFieldValue($==null?void 0:$.initialization.name,"VARIABLENAME"),h.getInput("EXPRESSION").connection.connect(P==null?void 0:P.outputConnection),k.getInput("INITIALIZATION").connection.connect(h==null?void 0:h.outputConnection);var C=Ze(y,$==null?void 0:$.condition);k.getInput("CONDITION").connection.connect(C.outputConnection);var g=Ze(y,$==null?void 0:$.incriment.value);d.setFieldValue($==null?void 0:$.incriment.name,"VARIABLENAME"),d.getInput("EXPRESSION").connection.connect(g==null?void 0:g.outputConnection),k.getInput("REASSIGNMENT").connection.connect(d==null?void 0:d.outputConnection);var f=Ze(y,$==null?void 0:$.statement);k.getInput("CODEBLOCK").connection.connect((F=f[0])==null?void 0:F.previousConnection),h.initSvg(),d.initSvg()}catch(A){console.error("An error occurred: could not generate the nested block",A),h.dispose(),d.dispose()}break;case"ARRAY":for(var _=$==null?void 0:$.params,v=y.newBlock("praxly_parameter_block"),a=0;a<((_==null?void 0:_.length)??0);a++){v.appendValueInput(`PARAM_${a}`);var l=y.newBlock("praxly_literal_block");l.setFieldValue(Ze(y,_[a]),"LITERAL"),v.getInput(`PARAM_${a}`).connection.connect(l==null?void 0:l.outputConnection),l.initSvg()}var k=v;break;case"ARRAY_REFERENCE":var k=y.newBlock("praxly_array_reference_block");k.setFieldValue($.name,"VARIABLENAME");var I=Ze(y,$==null?void 0:$.index);k.getInput("INDEX").connection.connect(I==null?void 0:I.outputConnection);break;default:return null}return $.blockID=k.id,k.initSvg(),k},we=(y,$,r)=>{switch(console.log(y.type),y.type){case"INT":case"BOOLEAN":try{var l=y.value.toString();return y.startIndex=$,y.endIndex=$+l.length,y.beg=$,y.end=$+l.length,l}catch{return" "}case"VARIABLE":try{var l=y.name.toString();return y.startIndex=$,y.endIndex=$+l.length,y.beg=$,y.end=$+l.length,l}catch{return" "}case"STRING":try{var l='"'+y.value+'"';return y.startIndex=$,y.endIndex=$+l.length,y.beg=$,y.end=$+l.length,l}catch{return" "}case"COMMENT":try{var l=" ".repeat(r)+"/*"+y.value+`*/ -`;return y.startIndex=$,y.endIndex=artIndex+l.length,y.beg=$,y.end=$+l.length,l}catch{return" "}case"SINGLE_LINE_COMMENT":try{var l=" ".repeat(r)+y.value+` -`;return y.startIndex=$,y.endIndex=$+l.length,y.beg=$,y.end=$+l.length,l}catch{return" "}case"ADD":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" + ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"SUBTRACT":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" - ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"MULTIPLY":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" * ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"DIVIDE":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" / ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"EXPONENT":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" ^ ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"MOD":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" % ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"AND":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" and ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"OR":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" or ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"EQUALS":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" == ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"LESS_THAN_EQUAL":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" <= ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"GREATER_THAN_EQUAL":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" >= ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"GREATER_THAN":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" > ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"LESS_THAN":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m=" < ";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"NOT_EQUAL":y.beg=$;var p=we(y.left,$,r);y.startIndex=p.length;var m="≠";y.endIndex=y.startIndex+m.length;var B=we(y.right,y.endIndex,r);return y.end=y.endIndex+B.length,p+m+B;case"PRINT":y.beg=$,y.startIndex=$;var l=" ".repeat(r)+"print ";y.endIndex=$+l.length;var d=we(y.value,y.endIndex,r)+` -`;return y.end=y.endIndex+d.length,l+d;case"RETURN":y.beg=$,y.startIndex=$;var l=" ".repeat(r)+"return ";y.endIndex=$+l.length;var d=we(y.value,y.endIndex,r)+` -`;return y.end=y.endIndex+d.length,l+d;case"PROGRAM":return we(y.value,$,r);case"STATEMENT":y.beg=$,y.startIndex=$;var l=" ".repeat(r);y.endIndex=$+l.length;var d=we(y.value,y.endIndex,r)+` -`;return y.end=y.endIndex+d.length,l+d;case"CODEBLOCK":var P=y.statements.map(g=>{try{return we(g,$,r)}catch(_){return console.error("An error occurred: empty statement",_),null}});return P.join("");case"IF":y.beg=$,y.startIndex=$,y.endIndex=$+2;var l=" ".repeat(r)+"if (",s=we(y.condition,$+l.length,r)+`) -`,c=we(y.statement,$+l.length+s.length,r+1)+" ".repeat(r)+`end if -`;return y.end=$+l.length+s.length+c.length,l+s+c;case"IF_ELSE":y.beg=$,y.startIndex=$,y.endIndex=$+2;var l=" ".repeat(r)+"if (",s=we(y.condition,$+l.length,r)+`) -`,c=we(y.statement,$+l.length+s.length,r+1),C=" ".repeat(r)+`else -`+we(y.alternative,$+l.length+s.length+c.length,r+1)+" ".repeat(r)+`end if -`;return y.end=$+l.length+s.length+c.length+C.length,l+s+c+C;case"ASSIGNMENT":if(y.varType==="reassignment")try{y.beg=$;var f=y.name.toString();y.startIndex=$+f.length;var m=" = ";y.endIndex=y.startIndex+m.length;var d=we(y.value,y.endIndex,r)+` -`;return y.end=y.endIndex+d.length," ".repeat(r)+f+m+d}catch{return" "}else try{y.beg=$;var f=y.varType.toString().substring(7)+" "+y.name.toString();y.startIndex=$+f.length+1;var m=" = ";y.endIndex=y.startIndex+1;var d=we(y.value,y.endIndex,r)+` -`;return y.end=y.endIndex+d.length," ".repeat(r)+f+m+d}catch(g){return console.error(g)," "}case"WHILE":y.beg=$,y.startIndex=$+r;var l=" ".repeat(r)+"while";y.endIndex=y.beg+l.length;var s=" ("+we(y.condition,$+l.length,r)+`) -`,c=" ".repeat(r)+we(y.statement,$+l.length+s.length,r+1)+" ".repeat(r)+`end while -`;return y.end=l.length+s.length+c.length,l+s+c;case"DO_WHILE":y.beg=$,y.startIndex=$+r;var l=" ".repeat(r)+`do -`;y.endIndex=$+l.length;var c=" ".repeat(r)+we(y.statement,$+l.length,r+1),s=" ".repeat(r)+"while ("+we(y.condition,$+l.length+c.length,r)+`) -`;return y.end=$+l.length+c.length+s.length,l+c+s;case"REPEAT_UNTIL":y.beg=$,y.startIndex=$+r;var l=" ".repeat(r)+`repeat -`;y.endIndex=$+l.length;var c=" ".repeat(r)+we(y.statement,$+l.length,r+1),s=" ".repeat(r)+"until ("+we(y.condition,$+l.length+c.length,r)+`) -`;return y.end=$+l.length+c.length+s.length,l+c+s;case"NOT":y.beg=$,y.startIndex=$;var l="not ";y.endIndex=$+l.length;var d=we(y.value,y.endIndex,r);return y.end=y.endIndex+d.length,l+d;case"FOR":y.beg=$,y.startIndex=$+r;var l=" ".repeat(r)+"for";y.endIndex=$+l.length;var a=" ("+we(y.initialization,$+l.length,r);a=a.slice(0,-1)+"; ";var s=we(y.condition,$+l.length+a.length,r)+"; ",o=we(y.incriment,$+l.length+a.length+s.length,r);o=o.slice(0,-1)+`) -`;var c=" ".repeat(r)+we(y.statement,$+l.length+a.length+s.length+o.length,r+1)+" ".repeat(r)+`end for -`;return y.end=$+l.length+a.length+s.length+o.length+c.length,l+a+s+o+c;case"FUNCTION_ASSIGNMENT":y.beg=$,y.startIndex=$;var l=y.returnType+" "+y.name+"(";y.endIndex=$+l.length-1;var h=y.params;h!==null&&h.length!==0&&(h.forEach(g=>{l+=g[0]+" "+g[1]+", "}),l=l.slice(0,l.length-2)),l+=")",l+=` -`;var c=" ".repeat(r)+we(y.contents,$+l.length,r+1);return l+=c,l+=" ".repeat(r)+`end ${y.name} -`,y.end=$+l.length,l;case"FUNCTION_CALL":y.beg=$,y.startIndex=$;var l=y.name+"(";y.endIndex=$+l.length-1;var h=y.params;return h!==null&&h.length>0&&(h.forEach(g=>{l+=we(g,$+l.length,r)+", "}),l=l.slice(0,l.length-2)),l+=")",y.end=$+l.length,l;case"ARRAY":y.beg=$,y.startIndex=$;var l="{";y.endIndex=$+l.length-1;var h=y.params;return h!==null&&h.length>0&&(h.forEach(g=>{l+=we(g,$+l.length,r)+", "}),l=l.slice(0,l.length-2)),l+="}",y.end=$+l.length,l;case"ARRAY_REFERENCE":y.beg=$,y.startIndex=$,l=y.name+"[",y.endIndex=$+l.length-1;var d=we(y.index,y.endIndex,r)+"]";return y.end=y.endIndex+d.length,l+d}};function Z_(y){let $={saveExtraState:function(){return{params:this.params}},loadExtraState:function(r){this.params=r.params||[];for(let p=0;p{let B=`PARAM_${this.params.length}`;this.id,this.appendValueInput(B),this.params.push(B)}),r.setOnClickHandler(()=>{const m=this.params.length;m>0&&(this.params.pop(),this.removeInput(`PARAM_${m-1}`))})}),ri.common.defineBlocksWithJsonArray([{type:"praxly_if_block",style:"logic_blocks",message0:"if ( %1 ) %2 %3 end if",args0:[{type:"input_value",name:"CONDITION",check:"Boolean"},{type:"input_dummy"},{type:"input_statement",name:"STATEMENT"}],previousStatement:null,nextStatement:null,tooltip:`place a condition inside the parintheses. This condition must evaluate to either true or false. +`))||(this.advance(),p.end=this.tokens[this.i].endIndex),p}else if(this.has("print")){this.advance();const o=this.boolean_operation();if(this.has(";")&&this.advance(),this.has(` +`))return p.type="PRINT",p.value=o,p.end=o==null?void 0:o.end,p}else if(this.has("return")){this.advance();const o=this.boolean_operation();if(this.has(";")&&this.advance(),this.has(` +`))return p.type="RETURN",p.value=o,p.end=o.end,p}else{if(this.has("comment"))return p.type="COMMENT",p.value=this.tokens[this.i].value,p.end=p.endIndex,p;if(this.has("single_line_comment"))return p.type="SINGLE_LINE_COMMENT",p.value=this.tokens[this.i].value,p.end=p.endIndex,p;if(this.has_type()&&this.has_ahead("Variable")){var m="Praxly_"+this.tokens[this.i].value;return this.advance(),this.has("Variable")&&(p.type="ASSIGNMENT",p.name=this.tokens[this.i].value,this.advance(),this.has("Assignment")&&(p.startIndex=this.tokens[this.i].startIndex,p.endIndex=this.tokens[this.i].endIndex,this.advance(),p.value=this.boolean_operation(),p.end=p.value.end,p.varType=m)),p}else if(this.has_type()&&this.has_ahead("[")){var m="Praxly_"+this.tokens[this.i].value;return this.advance(),this.advance(),this.has("]")?this.advance():gn("parsing","did not detect closing bracket",$,s),this.has("Variable")&&(p.type="ARRAY_ASSIGNMENT",p.name=this.tokens[this.i].value,this.advance(),this.has("Assignment")&&(p.startIndex=this.tokens[this.i].startIndex,p.endIndex=this.tokens[this.i].endIndex,this.advance(),p.value=this.boolean_operation(),p.end=p.value.end,p.varType=m)),p}else if(this.has("Variable")&&this.has_ahead("[")&&this.has_array_reference_assignment()){if(p.name=this.tokens[this.i].value,this.advance(),this.has("[")){this.advance();var B=this.boolean_operation();this.has("]")?this.advance():gn("parsing","did not detect closing bracket",$,s),p.type="ARRAY_REFERENCE_ASSIGNMENT",p.index=B,this.has("Assignment")?(p.startIndex=this.tokens[this.i].startIndex,this.advance(),p.value=this.boolean_operation(),p.end=p.value.end):console.error("the array reference asssignement function failed. ")}return this.has(";")&&this.advance(),p}else{if(this.has("Variable")&&this.has_ahead("Assignment"))return this.has("Variable")&&(p.type="ASSIGNMENT",p.name=this.tokens[this.i].value,this.advance(),this.has("Assignment")&&(p.startIndex=this.tokens[this.i].startIndex,this.advance(),p.value=this.boolean_operation(),p.end=p.value.end,p.varType="reassignment")),this.has(";")&&this.advance(),p;if(this.has_type()&&this.has_ahead("function")){p.type="FUNCTION_ASSIGNMENT",p.returnType=this.tokens[this.i].value,this.advance(),this.hasNot("function")&&console.error("no function name here, there is a problem"),p.name=this.tokens[this.i].value,this.advance();var P=[];if(this.has("(")){this.advance();for(var C=0;this.hasNot(")")&&C<_u;){var f=[];this.has_type()&&(f.push(this.tokens[this.i].value),this.advance()),this.has("Variable")&&(f.push(this.tokens[this.i].value),this.advance()),P.push(f),this.has(",")&&this.advance(),C+=1}console.log("here are the params"),console.log(P),this.has(")")?this.advance():(console.error("missing closing parinthesees"),gl("didnt detect closing parintheses in the arguments of a function definition",this.tokens[this.i].startIndex,this.tokens[this.i].endIndex)),p.params=P,p.endindex=this.tokens[this.i].endIndex,this.has(";")&&this.advance(),this.has(` +`)&&this.advance()}else{console.error("error, detected function but did not find parinthesees");return}var a=this.codeBlock("end "+p.name);return this.hasNot("end "+p.name)?(console.error("missing end function token"),p):(p.contents=a,p.end=(r=this.tokens[this.i])==null?void 0:r.endIndex,this.advance(),p)}else{if(this.has("/n"))return;{let o=this.boolean_operation();if(o==null)return;this.has(";")&&this.advance(),this.has(` +`)&&(p={type:"STATEMENT",value:o,blockID:"code"})}}}}return p}}function J_(T){for(let s=0;s{var I,w,x,N,D,R,S,F;switch($==null?void 0:$.type){case"COMMENT":var y=T.newBlock("praxly_comment_block");y.setFieldValue($.value,"COMMENT");break;case"SINGLE_LINE_COMMENT":var y=T.newBlock("praxly_single_line_comment_block");y.setFieldValue($.value,"COMMENT");break;case"INT":var y=T.newBlock("praxly_literal_block");y.setFieldValue($.value,"LITERAL");break;case"BOOLEAN":var y=0;$.value==="true"&&(y=T.newBlock("praxly_true_block")),$.value==="false"&&(y=T.newBlock("praxly_false_block"));break;case"STRING":var y=T.newBlock("praxly_literal_block");y.setFieldValue('"'+$.value+'"',"LITERAL");break;case"DOUBLE":case"CHAR":var y=T.newBlock("praxly_literal_block");y.setFieldValue($.value,"LITERAL");break;case"ADD":case"SUBTRACT":case"MULTIPLY":case"DIVIDE":case"EXPONENT":case"MOD":var y=T.newBlock("praxly_arithmetic_block"),s=He(T,$==null?void 0:$.left),p=He(T,$==null?void 0:$.right);y.setFieldValue($.type,"OPERATOR"),y.getInput("A_OPERAND").connection.connect(s==null?void 0:s.outputConnection),y.getInput("B_OPERAND").connection.connect(p==null?void 0:p.outputConnection);break;case"AND":case"OR":var y=T.newBlock("praxly_boolean_operators_block"),s=He(T,$==null?void 0:$.left),p=He(T,$==null?void 0:$.right);y.setFieldValue($.type,"OPERATOR"),y.getInput("A_OPERAND").connection.connect(s==null?void 0:s.outputConnection),y.getInput("B_OPERAND").connection.connect(p==null?void 0:p.outputConnection);break;case"EQUALS":case"LESS_THAN_EQUAL":case"GREATER_THAN_EQUAL":case"GREATER_THAN":case"LESS_THAN":case"NOT_EQUAL":var y=T.newBlock("praxly_compare_block"),s=He(T,$==null?void 0:$.left),p=He(T,$==null?void 0:$.right);y.getInput("A_OPERAND").connection.connect(s==null?void 0:s.outputConnection),y.getInput("B_OPERAND").connection.connect(p==null?void 0:p.outputConnection),y.setFieldValue($.type,"OPERATOR");break;case"PRINT":var y=T.newBlock("praxly_print_block"),v=He(T,$==null?void 0:$.value);y.getInput("EXPRESSION").connection.connect(v==null?void 0:v.outputConnection);break;case"CODEBLOCK":var m=$.statements.map(A=>{try{return He(T,A)}catch(E){return console.error("An error occurred: empty statement",E),null}});return J_(m),m;case"PROGRAM":return He(T,$.value);case"STATEMENT":var y=T.newBlock("praxly_statement_block"),v=He(T,$==null?void 0:$.value);y.getInput("EXPRESSION").connection.connect(v==null?void 0:v.outputConnection);break;case"IF":var y=T.newBlock("praxly_if_block"),P=He(T,$==null?void 0:$.condition),C=He(T,$==null?void 0:$.statement);y.getInput("CONDITION").connection.connect(P==null?void 0:P.outputConnection),y.getInput("STATEMENT").connection.connect((I=C[0])==null?void 0:I.previousConnection);break;case"IF_ELSE":var y=T.newBlock("praxly_if_else_block"),P=He(T,$==null?void 0:$.condition),m=He(T,$==null?void 0:$.statement),B=He(T,$==null?void 0:$.alternative);y.getInput("CONDITION").connection.connect(P==null?void 0:P.outputConnection),y.getInput("STATEMENT").connection.connect((w=m[0])==null?void 0:w.previousConnection),y.getInput("ALTERNATIVE").connection.connect((x=B[0])==null?void 0:x.previousConnection);break;case"VARIABLE":var y=T.newBlock("praxly_variable_block");y.setFieldValue($.name,"LITERAL");break;case"ASSIGNMENT":var M=He(T,$==null?void 0:$.value);if($.varType==="reassignment")var y=T.newBlock("praxly_reassignment_block");else{var y=T.newBlock("praxly_assignment_block");$.varType==="Praxly_array"?(y.dispose(),y=T.newBlock("praxly_array_assignment_block"),y.setFieldValue("int[]","VARTYPE")):y.setFieldValue($.varType.substring(7),"VARTYPE")}y.setFieldValue($.name,"VARIABLENAME"),y.getInput("EXPRESSION").connection.connect(M==null?void 0:M.outputConnection);break;case"WHILE":var y=T.newBlock("praxly_while_loop_block"),P=He(T,$==null?void 0:$.condition),C=He(T,$==null?void 0:$.statement);y.getInput("CONDITION").connection.connect(P==null?void 0:P.outputConnection),y.getInput("STATEMENT").connection.connect((N=C[0])==null?void 0:N.previousConnection);break;case"DO_WHILE":var y=T.newBlock("praxly_do_while_loop_block"),P=He(T,$==null?void 0:$.condition),C=He(T,$==null?void 0:$.statement);y.getInput("CONDITION").connection.connect(P==null?void 0:P.outputConnection),y.getInput("STATEMENT").connection.connect((D=C[0])==null?void 0:D.previousConnection);break;case"REPEAT_UNTIL":var y=T.newBlock("praxly_repeat_until_loop_block"),P=He(T,$==null?void 0:$.condition),C=He(T,$==null?void 0:$.statement);y.getInput("CONDITION").connection.connect(P==null?void 0:P.outputConnection),y.getInput("STATEMENT").connection.connect((R=C[0])==null?void 0:R.previousConnection);break;case"NOT":var y=T.newBlock("praxly_not_block"),v=He(T,$==null?void 0:$.value);y.getInput("EXPRESSION").connection.connect(v==null?void 0:v.outputConnection);break;case"RETURN":var y=T.newBlock("praxly_return_block"),v=He(T,$==null?void 0:$.value);y.getInput("EXPRESSION").connection.connect(v==null?void 0:v.outputConnection);break;case"FUNCTION_CALL":var y=T.newBlock("praxly_function_call_block"),_=T.newBlock("praxly_parameter_block");y.setFieldValue($==null?void 0:$.name,"PROCEDURE_NAME"),y.getInput("PARAMS").connection.connect(_==null?void 0:_.outputConnection);for(var g=$==null?void 0:$.params,f=0;f<((g==null?void 0:g.length)??0);f++){_.appendValueInput(`PARAM_${f}`);var a=He(T,g[f]);_.getInput(`PARAM_${f}`).connection.connect(a==null?void 0:a.outputConnection)}_.initSvg();break;case"FUNCTION_ASSIGNMENT":var r=$==null?void 0:$.returnType,g=$==null?void 0:$.params,y=T.newBlock("praxly_procedure_block"),_=T.newBlock("praxly_parameter_block");y.setFieldValue(r,"RETURNTYPE"),y.setFieldValue($==null?void 0:$.name,"PROCEDURE_NAME"),y.setFieldValue($==null?void 0:$.name,"END_PROCEDURE_NAME"),y.getInput("PARAMS").connection.connect(_==null?void 0:_.outputConnection);var o=He(T,$==null?void 0:$.contents);y.getInput("CONTENTS").connection.connect((S=o[0])==null?void 0:S.previousConnection);for(var f=0;f<((g==null?void 0:g.length)??0);f++){_.appendValueInput(`PARAM_${f}`);var c=T.newBlock("praxly_singular_param_block");c.setFieldValue(g[f][0],"VARTYPE"),c.setFieldValue(g[f][1],"VARIABLENAME"),_.getInput(`PARAM_${f}`).connection.connect(c==null?void 0:c.outputConnection),c.initSvg()}_.initSvg();break;case"FOR":var y=T.newBlock("praxly_for_loop_block");try{var l=T.newBlock("praxly_assignment_expression_block"),h=T.newBlock("praxly_reassignment_expression_block"),M=He(T,$==null?void 0:$.initialization.value);l.setFieldValue($==null?void 0:$.initialization.varType.substring(7),"VARTYPE"),l.setFieldValue($==null?void 0:$.initialization.name,"VARIABLENAME"),l.getInput("EXPRESSION").connection.connect(M==null?void 0:M.outputConnection),y.getInput("INITIALIZATION").connection.connect(l==null?void 0:l.outputConnection);var P=He(T,$==null?void 0:$.condition);y.getInput("CONDITION").connection.connect(P.outputConnection);var d=He(T,$==null?void 0:$.incriment.value);h.setFieldValue($==null?void 0:$.incriment.name,"VARIABLENAME"),h.getInput("EXPRESSION").connection.connect(d==null?void 0:d.outputConnection),y.getInput("REASSIGNMENT").connection.connect(h==null?void 0:h.outputConnection);var C=He(T,$==null?void 0:$.statement);y.getInput("CODEBLOCK").connection.connect((F=C[0])==null?void 0:F.previousConnection),l.initSvg(),h.initSvg()}catch(A){console.error("An error occurred: could not generate the nested block",A),l.dispose(),h.dispose()}break;case"ARRAY":for(var g=$==null?void 0:$.params,_=T.newBlock("praxly_parameter_block"),f=0;f<((g==null?void 0:g.length)??0);f++){_.appendValueInput(`PARAM_${f}`);var c=He(T,g[f]);_.getInput(`PARAM_${f}`).connection.connect(c==null?void 0:c.outputConnection)}var y=_;break;case"ARRAY_REFERENCE":var y=T.newBlock("praxly_array_reference_block");y.setFieldValue($.name,"VARIABLENAME");var v=He(T,$==null?void 0:$.index);y.getInput("INDEX").connection.connect(v==null?void 0:v.outputConnection);break;case"ARRAY_REFERENCE_ASSIGNMENT":var y=T.newBlock("praxly_array_reference_reassignment_block");console.error("reached here"),y.setFieldValue($.name,"VARIABLENAME");var v=He(T,$==null?void 0:$.index);y.getInput("INDEX").connection.connect(v==null?void 0:v.outputConnection);var M=He(T,$==null?void 0:$.value);y.getInput("EXPRESSION").connection.connect(M==null?void 0:M.outputConnection);break;case"ARRAY_ASSIGNMENT":var M=He(T,$==null?void 0:$.value),y=T.newBlock("praxly_array_assignment_block");y.setFieldValue($==null?void 0:$.varType,"VARTYPE"),y.setFieldValue($==null?void 0:$.name,"VARIABLENAME"),y.getInput("EXPRESSION").connection.connect(M==null?void 0:M.outputConnection);break;default:return null}return $.blockID=y.id,y.initSvg(),y},we=(T,$,s)=>{switch(console.log(T.type),T.type){case"INT":case"BOOLEAN":try{var l=T.value.toString();return T.startIndex=$,T.endIndex=$+l.length,T.beg=$,T.end=$+l.length,l}catch{return" "}case"VARIABLE":try{var l=T.name.toString();return T.startIndex=$,T.endIndex=$+l.length,T.beg=$,T.end=$+l.length,l}catch{return" "}case"STRING":try{var l='"'+T.value+'"';return T.startIndex=$,T.endIndex=$+l.length,T.beg=$,T.end=$+l.length,l}catch{return" "}case"COMMENT":try{var l=" ".repeat(s)+"/*"+T.value+`*/ +`;return T.startIndex=$,T.endIndex=artIndex+l.length,T.beg=$,T.end=$+l.length,l}catch{return" "}case"SINGLE_LINE_COMMENT":try{var l=" ".repeat(s)+T.value+` +`;return T.startIndex=$,T.endIndex=$+l.length,T.beg=$,T.end=$+l.length,l}catch{return" "}case"ADD":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" + ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"SUBTRACT":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" - ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"MULTIPLY":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" * ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"DIVIDE":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" / ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"EXPONENT":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" ^ ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"MOD":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" % ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"AND":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" and ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"OR":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" or ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"EQUALS":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" == ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"LESS_THAN_EQUAL":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" <= ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"GREATER_THAN_EQUAL":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" >= ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"GREATER_THAN":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" > ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"LESS_THAN":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m=" < ";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"NOT_EQUAL":T.beg=$;var p=we(T.left,$,s);T.startIndex=p.length;var m="≠";T.endIndex=T.startIndex+m.length;var B=we(T.right,T.endIndex,s);return T.end=T.endIndex+B.length,p+m+B;case"PRINT":T.beg=$,T.startIndex=$;var l=" ".repeat(s)+"print ";T.endIndex=$+l.length;var d=we(T.value,T.endIndex,s)+` +`;return T.end=T.endIndex+d.length,l+d;case"RETURN":T.beg=$,T.startIndex=$;var l=" ".repeat(s)+"return ";T.endIndex=$+l.length;var d=we(T.value,T.endIndex,s)+` +`;return T.end=T.endIndex+d.length,l+d;case"PROGRAM":return we(T.value,$,s);case"STATEMENT":T.beg=$,T.startIndex=$;var l=" ".repeat(s);T.endIndex=$+l.length;var d=we(T.value,T.endIndex,s)+` +`;return T.end=T.endIndex+d.length,l+d;case"CODEBLOCK":var P=T.statements.map(_=>{try{return we(_,$,s)}catch(v){return console.error("An error occurred: empty statement",v),null}});return P.join("");case"IF":T.beg=$,T.startIndex=$,T.endIndex=$+2;var l=" ".repeat(s)+"if (",r=we(T.condition,$+l.length,s)+`) +`,c=we(T.statement,$+l.length+r.length,s+1)+" ".repeat(s)+`end if +`;return T.end=$+l.length+r.length+c.length,l+r+c;case"IF_ELSE":T.beg=$,T.startIndex=$,T.endIndex=$+2;var l=" ".repeat(s)+"if (",r=we(T.condition,$+l.length,s)+`) +`,c=we(T.statement,$+l.length+r.length,s+1),C=" ".repeat(s)+`else +`+we(T.alternative,$+l.length+r.length+c.length,s+1)+" ".repeat(s)+`end if +`;return T.end=$+l.length+r.length+c.length+C.length,l+r+c+C;case"ASSIGNMENT":if(T.varType==="reassignment")try{T.beg=$;var f=T.name.toString();T.startIndex=$+f.length;var m=" = ";T.endIndex=T.startIndex+m.length;var d=we(T.value,T.endIndex,s)+` +`;return T.end=T.endIndex+d.length," ".repeat(s)+f+m+d}catch{return" "}else try{T.beg=$;var f=T.varType.toString().substring(7)+" "+T.name.toString();T.startIndex=$+f.length+1;var m=" = ";T.endIndex=T.startIndex+1;var d=we(T.value,T.endIndex,s)+` +`;return T.end=T.endIndex+d.length," ".repeat(s)+f+m+d}catch(_){return console.error(_)," "}case"WHILE":T.beg=$,T.startIndex=$+s;var l=" ".repeat(s)+"while";T.endIndex=T.beg+l.length;var r=" ("+we(T.condition,$+l.length,s)+`) +`,c=" ".repeat(s)+we(T.statement,$+l.length+r.length,s+1)+" ".repeat(s)+`end while +`;return T.end=l.length+r.length+c.length,l+r+c;case"DO_WHILE":T.beg=$,T.startIndex=$+s;var l=" ".repeat(s)+`do +`;T.endIndex=$+l.length;var c=" ".repeat(s)+we(T.statement,$+l.length,s+1),r=" ".repeat(s)+"while ("+we(T.condition,$+l.length+c.length,s)+`) +`;return T.end=$+l.length+c.length+r.length,l+c+r;case"REPEAT_UNTIL":T.beg=$,T.startIndex=$+s;var l=" ".repeat(s)+`repeat +`;T.endIndex=$+l.length;var c=" ".repeat(s)+we(T.statement,$+l.length,s+1),r=" ".repeat(s)+"until ("+we(T.condition,$+l.length+c.length,s)+`) +`;return T.end=$+l.length+c.length+r.length,l+c+r;case"NOT":T.beg=$,T.startIndex=$;var l="not ";T.endIndex=$+l.length;var d=we(T.value,T.endIndex,s);return T.end=T.endIndex+d.length,l+d;case"FOR":T.beg=$,T.startIndex=$+s;var l=" ".repeat(s)+"for";T.endIndex=$+l.length;var a=" ("+we(T.initialization,$+l.length,s);a=a.slice(0,-1)+"; ";var r=we(T.condition,$+l.length+a.length,s)+"; ",o=we(T.incriment,$+l.length+a.length+r.length,s);o=o.slice(0,-1)+`) +`;var c=" ".repeat(s)+we(T.statement,$+l.length+a.length+r.length+o.length,s+1)+" ".repeat(s)+`end for +`;return T.end=$+l.length+a.length+r.length+o.length+c.length,l+a+r+o+c;case"FUNCTION_ASSIGNMENT":T.beg=$,T.startIndex=$;var l=T.returnType+" "+T.name+"(";T.endIndex=$+l.length-1;var h=T.params;h!==null&&h.length!==0&&(h.forEach(_=>{l+=_[0]+" "+_[1]+", "}),l=l.slice(0,l.length-2)),l+=")",l+=` +`;var c=" ".repeat(s)+we(T.contents,$+l.length,s+1);return l+=c,l+=" ".repeat(s)+`end ${T.name} +`,T.end=$+l.length,l;case"FUNCTION_CALL":T.beg=$,T.startIndex=$;var l=T.name+"(";T.endIndex=$+l.length-1;var h=T.params;return h!==null&&h.length>0&&(h.forEach(_=>{l+=we(_,$+l.length,s)+", "}),l=l.slice(0,l.length-2)),l+=")",T.end=$+l.length,l;case"ARRAY":T.beg=$,T.startIndex=$;var l="{";T.endIndex=$+l.length-1;var h=T.params;return h!==null&&h.length>0&&(h.forEach(_=>{l+=we(_,$+l.length,s)+", "}),l=l.slice(0,l.length-2)),l+="}",T.end=$+l.length,l;case"ARRAY_REFERENCE":T.beg=$,T.startIndex=$,l=T.name+"[",T.endIndex=$+l.length-1;var d=we(T.index,T.endIndex,s)+"]";return T.end=T.endIndex+d.length,l+d;case"ARRAY_ASSIGNMENT":try{T.beg=$;var f=T.varType.toString().substring(7)+"[] "+T.name.toString();T.startIndex=$+f.length+1;var m=" = ";T.endIndex=T.startIndex+1;var l="{",h=T.value.params;return h!==null&&h.length>0&&(h.forEach(I=>{l+=we(I,$+l.length,s)+", "}),l=l.slice(0,l.length-2)),l+=`} +`,T.end=T.endIndex+l.length," ".repeat(s)+f+m+l}catch(_){return console.error(_),"assignemnt for arrays borke "}case"ARRAY_REFERENCE_ASSIGNMENT":try{T.beg=$;var g=we(T.index,T.endIndex,s)+"]",f=T.name.toString()+"["+g;T.startIndex=$+f.length;var m=" = ";T.endIndex=T.startIndex+m.length;var d=we(T.value,T.endIndex,s)+` +`;return T.end=T.endIndex+d.length," ".repeat(s)+f+m+d}catch{return" "}}};function Z_(T){let $={saveExtraState:function(){return{params:this.params}},loadExtraState:function(s){this.params=s.params||[];for(let p=0;p{let B=`PARAM_${this.params.length}`;this.id,this.appendValueInput(B),this.params.push(B)}),s.setOnClickHandler(()=>{const m=this.params.length;m>0&&(this.params.pop(),this.removeInput(`PARAM_${m-1}`))})}),ri.common.defineBlocksWithJsonArray([{type:"praxly_if_block",style:"logic_blocks",message0:"if ( %1 ) %2 %3 end if",args0:[{type:"input_value",name:"CONDITION",check:"Boolean"},{type:"input_dummy"},{type:"input_statement",name:"STATEMENT"}],previousStatement:null,nextStatement:null,tooltip:`place a condition inside the parintheses. This condition must evaluate to either true or false. If the condition is true, then the code below will be ran. Otherwise, it is skipped.`,helpUrl:""},{type:"praxly_if_else_block",message0:"if ( %1 ) %2 %3 else %4 %5 end if",args0:[{type:"input_value",name:"CONDITION",check:"Boolean"},{type:"input_dummy"},{type:"input_statement",name:"STATEMENT"},{type:"input_dummy"},{type:"input_statement",name:"ALTERNATIVE"}],previousStatement:null,nextStatement:null,style:"logic_blocks",tooltip:`place a condition inside the parintheses. This condition must evaluate to either true or false. - If the condition is true, then only the blocks underneach the first line will be ran. If the condition is false, then oonly the blocks in the else statement will be ran.`,helpUrl:""},{type:"praxly_while_loop_block",message0:"while ( %1 ) %2 %3 end while",args0:[{type:"input_value",name:"CONDITION"},{type:"input_dummy"},{type:"input_statement",name:"STATEMENT"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"place a condition inside the parintheses. This condition must evaluate to either true or false. the blocks inside this block will be ran over and over again until the condition is no longer true",helpUrl:""},{type:"praxly_do_while_loop_block",message0:"do %1 while (%2 )%3 ",args0:[{type:"input_statement",name:"STATEMENT"},{type:"input_value",name:"CONDITION"},{type:"input_dummy"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"",helpUrl:""},{type:"praxly_repeat_until_loop_block",message0:"repeat %1 until (%2 )%3 ",args0:[{type:"input_statement",name:"STATEMENT"},{type:"input_value",name:"CONDITION"},{type:"input_dummy"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"",helpUrl:""},{type:"praxly_for_loop_block",message0:"for (%1 ; %2 ; %3 )%4 %5 end for",args0:[{type:"input_value",name:"INITIALIZATION"},{type:"input_value",name:"CONDITION"},{type:"input_value",name:"REASSIGNMENT"},{type:"input_dummy"},{type:"input_statement",name:"CODEBLOCK"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"",helpUrl:""},{type:"praxly_null_block",message0:"null",inputsInline:!0,output:null,style:"expression_blocks",tooltip:"",helpUrl:""},{type:"praxly_true_block",message0:"true",inputsInline:!0,output:"Boolean",style:"expression_blocks",tooltip:"",helpUrl:""},{type:"praxly_false_block",message0:"false",inputsInline:!0,output:"Boolean",style:"expression_blocks",tooltip:"",helpUrl:""},{type:"praxly_compare_block",message0:"%1 %2 %3 %4",args0:[{type:"input_value",name:"A_OPERAND"},{type:"field_dropdown",name:"OPERATOR",options:[["==","EQUALS"],["<=","LESS_THAN_EQUAL"],[">=","GREATER_THAN_EQUAL"],["≠","NOT_EQUAL"],["<","LESS_THAN"],[">","GREATER_THAN"]]},{type:"input_dummy"},{type:"input_value",name:"B_OPERAND"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",tooltip:"",helpUrl:""},{type:"praxly_arithmetic_block",message0:"%1 %2 %3 %4",args0:[{type:"input_value",name:"A_OPERAND"},{type:"field_dropdown",name:"OPERATOR",options:[["+","ADD"],["-","SUBTRACT"],["*","MULTIPLY"],["/","DIVIDE"],["%","MOD"],["^","EXPONENT"]]},{type:"input_dummy"},{type:"input_value",name:"B_OPERAND"}],inputsInline:!0,output:null,style:"expression_blocks",tooltip:"",helpUrl:""},{type:"praxly_boolean_operators_block",message0:"%1 %2 %3 %4",args0:[{type:"input_value",name:"A_OPERAND",check:"Boolean"},{type:"field_dropdown",name:"OPERATOR",options:[["and","AND"],["or","OR"]]},{type:"input_dummy"},{type:"input_value",name:"B_OPERAND",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",tooltip:"",helpUrl:""},{type:"praxly_comment_block",message0:"/* %1 %2 */",args0:[{type:"input_dummy"},{type:"field_input",name:"COMMENT",text:"comment"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"comment_blocks",tooltip:"",helpUrl:""},{type:"praxly_single_line_comment_block",message0:"// %1 %2",args0:[{type:"input_dummy"},{type:"field_input",name:"COMMENT",text:"comment"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"comment_blocks",tooltip:"",helpUrl:""},{type:"praxly_class_block",message0:"class %1 %2 end class",args0:[{type:"input_dummy"},{type:"input_statement",name:"class"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"class_blocks",tooltip:"",helpUrl:""},{type:"praxly_procedure_block",message0:"%1 %2 %3 ( %4 ) %5 %6 end %7",args0:[{type:"field_dropdown",name:"RETURNTYPE",options:[["int","int"],["boolean","boolean"],["double","double"],["char","char"],["String","String"],["float","float"],["short","short"]]},{type:"input_dummy"},{type:"field_input",name:"PROCEDURE_NAME",text:"procedureName"},{type:"input_value",name:"PARAMS",text:"params"},{type:"input_dummy"},{type:"input_statement",name:"CONTENTS"},{type:"field_input",name:"END_PROCEDURE_NAME",text:"procedureName"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"procedure_blocks",tooltip:"test",helpUrl:"",onchange:"updateProcedureName"},{type:"praxly_function_call_block",message0:"%1 (%2)",args0:[{type:"field_input",name:"PROCEDURE_NAME",text:"procedureName"},{type:"input_value",name:"PARAMS",text:"params"}],inputsInline:!0,output:null,style:"procedure_blocks",tooltip:"test",helpUrl:"",onchange:"updateProcedureName"},{type:"praxly_assignment_block",message0:"%1%2 ⬅ %3 %4",args0:[{type:"field_dropdown",name:"VARTYPE",options:[["int","int"],["boolean","boolean"],["double","double"],["char","char"],["String","String"],["float","float"],["short","short"]]},{type:"field_input",name:"VARIABLENAME",text:"VariableName"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_reassignment_block",message0:"%1⬅%2 %3",args0:[{type:"field_input",name:"VARIABLENAME",text:"VariableName"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_return_block",message0:"return %1",args0:[{type:"input_value",name:"EXPRESSION"}],inputsInline:!0,previousStatement:null,style:"procedure_blocks",tooltip:"",helpUrl:""},{type:"praxly_print_block",message0:"print %1 %2",args0:[{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],previousStatement:null,nextStatement:null,style:"procedure_blocks",tooltip:"",helpUrl:""},{type:"praxly_statement_block",message0:"%1",args0:[{type:"input_value",name:"EXPRESSION"}],previousStatement:null,nextStatement:null,style:"procedure_blocks",tooltip:"",helpUrl:""},{type:"praxly_literal_block",message0:"%1",args0:[{type:"field_input",name:"LITERAL",text:"value"}],output:null,style:"expression_blocks",tooltip:"",helpUrl:""},{type:"praxly_variable_block",message0:"%1",args0:[{type:"field_input",name:"LITERAL",text:"name"}],output:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_String_block",message0:'"%1"',args0:[{type:"field_input",name:"LITERAL",text:"String"}],output:null,style:"expression_blocks",tooltip:"",helpUrl:""},{type:"custom_operation_block",message0:"Custom Operation %1 %2",args0:[{type:"input_value",name:"input1",check:"Number",align:"RIGHT",defaultType:"math_number",defaultValue:5},{type:"input_value",name:"input2",check:"Number",align:"RIGHT",defaultType:"math_number",defaultValue:10}],output:"Number",colour:230,tooltip:"Perform custom operation",helpUrl:""},{type:"praxly_assignment_expression_block",message0:"%1%2 ⬅ %3 %4",args0:[{type:"field_dropdown",name:"VARTYPE",options:[["int","int"],["boolean","boolean"],["double","double"],["char","char"],["String","String"],["float","float"],["short","short"]]},{type:"field_input",name:"VARIABLENAME",text:"i"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,output:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_not_block",message0:"not %1 %2",args0:[{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],output:"Boolean",style:"logic_blocks",tooltip:"",helpUrl:""},{type:"praxly_reassignment_expression_block",message0:"%1⬅%2 %3",args0:[{type:"field_input",name:"VARIABLENAME",text:"i"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,output:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_parameter_block",message0:"%1 %2",args0:[{type:"field_image",src:"https://iconsplace.com/wp-content/uploads/_icons/ffffff/256/png/plus-icon-18-256.png",name:"PLUS_BUTTON",width:19,height:19,alt:"*"},{type:"field_image",src:"https://iconsplace.com/wp-content/uploads/_icons/ffffff/256/png/minus-icon-256.png",name:"MINUS_BUTTON",width:19,height:19,alt:"*"}],output:null,style:"parameter_blocks",tooltip:"",helpUrl:"",mutator:"praxly_arity",extensions:["addParams"],inputsInline:!0},{type:"praxly_singular_param_block",message0:"%1%2",args0:[{type:"field_dropdown",name:"VARTYPE",options:[["int","int"],["boolean","boolean"],["double","double"],["char","char"],["String","String"],["float","float"],["short","short"]]},{type:"field_input",name:"VARIABLENAME",text:"i"}],inputsInline:!0,output:null,style:"parameter_blocks",tooltip:"",helpUrl:""},{type:"praxly_array_assignment_block",message0:"%1%2 ⬅ {%3 %4}",args0:[{type:"field_dropdown",name:"VARTYPE",options:[["int[]","int[]"],["int[][] (coming soon)","int[][] (coming soon)"]]},{type:"field_input",name:"VARIABLENAME",text:"arrayName"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_array_reference_block",message0:"%1[%2] %3",args0:[{type:"field_input",name:"VARIABLENAME",text:"arrayName"},{type:"input_value",name:"INDEX",text:"0"},{type:"input_dummy"}],inputsInline:!0,style:"variable_blocks",tooltip:"",helpUrl:"",output:null}])}function _m(y){return/^\d+$/.test(y)}const Q_=(y,$)=>{var r={type:"PROGRAM",blockID:"blocksRoot",value:$.codeBLockJsonBuilder(y.getTopBlocks()[0])};return r},q_=()=>{const y=[];return y.codeBLockJsonBuilder=$=>{var r={type:"CODEBLOCK",blockID:"blocks[]"},p=[];let m=$;for(;m.getNextBlock()!=null;)p.push(y[m.type](m)),m=m.getNextBlock();return p.push(y[m.type](m)),r.statements=p,r},y.praxly_arithmetic_block=$=>{const r=$.getChildren(!0),p=r[0],m=r[1],B={blockID:$.id,left:y[p.type](p),right:y[m.type](m)};return B.type=$.getFieldValue("OPERATOR"),B},y.praxly_print_block=$=>{const r=$.getInputTargetBlock("EXPRESSION");return{blockID:$.id,type:"PRINT",value:y[r.type](r)}},y.praxly_array_reference_block=$=>({blockID:$.id,type:"ARRAY_REFERENCE",name:$.getFieldValue("VARIABLENAME"),index:$.getInputTargetBlock("INDEX")}),y.praxly_literal_block=$=>{const r=$.getFieldValue("LITERAL"),p={blockID:$.id,value:r};return r[0]==='"'&&r[r.length-1]==='"'?(p.type="STRING",p.value=r.slice(1,-1)):r.includes(".")?p.type="DOUBLE":_m(r)?p.type="INT":(p.type="VARIABLE",p.name=r),p},y.praxly_variable_block=$=>{const r=$.getFieldValue("LITERAL"),p={blockID:$.id,value:r};return r[0]==='"'&&r[r.length-1]==='"'?(p.type="STRING",p.value=r.slice(1,-1)):r.includes(".")?p.type="DOUBLE":_m(r)?p.type="INT":(p.type="VARIABLE",p.name=r),p},y.praxly_boolean_operators_block=$=>{const r=$.getChildren(!0),p=r[0],m=r[1],B={blockID:$.id,left:y[p.type](p),right:y[m.type](m)};return B.type=$.getFieldValue("OPERATOR"),B},y.praxly_compare_block=$=>{const r=$.getChildren(!0),p=r[0],m=r[1],B={blockID:$.id,left:y[p.type](p),right:y[m.type](m)};return B.type=$.getFieldValue("OPERATOR"),B},y.praxly_true_block=$=>({blockID:$.id,value:!0,type:"BOOLEAN"}),y.praxly_false_block=$=>({blockID:$.id,value:!1,type:"BOOLEAN"}),y.praxly_comment_block=$=>({blockID:$.id,value:$.getFieldValue("COMMENT"),type:"COMMENT"}),y.praxly_single_line_comment_block=$=>({blockID:$.id,value:$.getFieldValue("COMMENT"),type:"SINGLE_LINE_COMMENT"}),y.praxly_if_block=$=>{const r=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT");return{type:"IF",blockID:$.id,condition:y[r.type](r),statement:y.codeBLockJsonBuilder(p)}},y.praxly_if_else_block=$=>{const r=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT"),m=$.getInputTargetBlock("ALTERNATIVE");return{type:"IF_ELSE",blockID:$.id,condition:y[r.type](r),statement:y.codeBLockJsonBuilder(p),alternative:y.codeBLockJsonBuilder(m)}},y.praxly_assignment_block=$=>{var r=$.getFieldValue("VARTYPE");console.log(`field input is ${r}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=y[m.type](m);return{type:"ASSIGNMENT",name:p,value:B,blockID:$.id,varType:"Praxly_"+r}},y.praxly_array_assignment_block=$=>{var r=$.getFieldValue("VARTYPE");console.log(`field input is ${r}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=m.getChildren(!0),P=[];return B.forEach(C=>{P.push(y[C.type](C))}),{type:"ASSIGNMENT",name:p,value:P,blockID:$.id,varType:"Praxly_array"}},y.praxly_reassignment_block=$=>{var r=$.getFieldValue("VARTYPE");console.log(`field input is ${r}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=y[m.type](m);return{type:"ASSIGNMENT",name:p,value:B,blockID:$.id,varType:"reassignment"}},y.praxly_assignment_expression_block=$=>{var r=$.getFieldValue("VARTYPE");console.log(`field input is ${r}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=y[m.type](m);return{type:"ASSIGNMENT",name:p,value:B,blockID:$.id,varType:"Praxly_"+r}},y.praxly_reassignment_expression_block=$=>{var r=$.getFieldValue("VARTYPE");console.log(`field input is ${r}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=y[m.type](m);return{type:"ASSIGNMENT",name:p,value:B,blockID:$.id,varType:"reassignment"}},y.praxly_while_loop_block=$=>{const r=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT");return{type:"WHILE",blockID:$.id,condition:y[r.type](r),statement:y.codeBLockJsonBuilder(p)}},y.praxly_do_while_loop_block=$=>{const r=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT");return{type:"DO_WHILE",blockID:$.id,condition:y[r.type](r),statement:y.codeBLockJsonBuilder(p)}},y.praxly_repeat_until_loop_block=$=>{const r=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT");return{type:"REPEAT_UNTIL",blockID:$.id,condition:y[r.type](r),statement:y.codeBLockJsonBuilder(p)}},y.praxly_not_block=$=>{const r=$.getInputTargetBlock("EXPRESSION");return{blockID:$.id,type:"NOT",value:y[r.type](r)}},y.praxly_for_loop_block=$=>{var r=$.getInputTargetBlock("INITIALIZATION"),p=$.getInputTargetBlock("CONDITION"),m=$.getInputTargetBlock("REASSIGNMENT");const B=$.getInputTargetBlock("CODEBLOCK");return{type:"FOR",blockID:$.id,initialization:y[r.type](r),statement:y.codeBLockJsonBuilder(B),incriment:y[m.type](m),condition:y[p.type](p)}},y.praxly_procedure_block=$=>{var r=$.getFieldValue("RETURNTYPE"),p=$.getInputTargetBlock("PARAMS"),m=p.getChildren(!0),B=[];m.forEach(f=>{var a=[];a[0]=f.getFieldValue("VARTYPE"),a[1]=f.getFieldValue("VARIABLENAME"),B.push(a)});var P=$.getFieldValue("PROCEDURE_NAME");const C=$.getInputTargetBlock("CONTENTS");return $.setFieldValue(P,"END_PROCEDURE_NAME"),{type:"FUNCTION_ASSIGNMENT",name:P,params:B,returnType:r,contents:y.codeBLockJsonBuilder(C),blockID:$.id}},y.praxly_function_call_block=$=>{var r=$.getFieldValue("PROCEDURE_NAME"),p=$.getInputTargetBlock("PARAMS"),m=p.getChildren(!0),B=[];return m.forEach(P=>{B.push(y[P.type](P))}),{blockID:$.id,type:"FUNCTION_CALL",name:r,params:B}},y.praxly_return_block=$=>{const r=$.getInputTargetBlock("EXPRESSION");return{blockID:$.id,type:"RETURN",value:y[r.type](r)}},y};var Om={};class Lm extends Error{constructor($){super(`attempting to return. this should return ${$}`),this.name=this.constructor.name,this.errorData=$}}const Se=y=>{if(typeof y>"u"||typeof y.type>"u")return console.error("error constructing the tree: reached an invalid branch that is either undefined or has an undefined type"),new Tl;switch(console.log(y.type),y.type){case"INT":return new xt(y.value,y);case"STRING":return new Qt(y.value,y);case"BOOLEAN":return new bt(y.value,y);case"DOUBLE":return new Bt(y.value,y);case"ADD":return new r$(Se(y.left),Se(y.right),y);case"SUBTRACT":return new o$(Se(y.left),Se(y.right),y);case"MULTIPLY":return new l$(Se(y.left),Se(y.right),y);case"DIVIDE":return new a$(Se(y.left),Se(y.right),y);case"EXPONENT":return new h$(Se(y.left),Se(y.right),y);case"MOD":return new c$(Se(y.left),Se(y.right),y);case"AND":return new u$(Se(y.left),Se(y.right),y);case"OR":return new d$(Se(y.left),Se(y.right),y);case"EQUALS":return new p$(Se(y.left),Se(y.right),y);case"LESS_THAN_EQUAL":return new $$(Se(y.left),Se(y.right),y);case"GREATER_THAN_EQUAL":return new _$(Se(y.left),Se(y.right),y);case"GREATER_THAN":return new f$(Se(y.left),Se(y.right),y);case"LESS_THAN":return new m$(Se(y.left),Se(y.right),y);case"NOT_EQUAL":return new g$(Se(y.left),Se(y.right),y);case"PRINT":return new n$(Se(y.value),y);case"CODEBLOCK":let f=y.statements.map(a=>{try{return Se(a)}catch{return new vm(y)}});return new b$(f);case"PROGRAM":return Om={global:{variableList:{},functionList:{}}},new E$(Se(y.value));case"STATEMENT":try{return new Pn(Se(y.value),y)}catch{return new vm(y)}case"IF":try{return new v$(Se(y.condition),Se(y.statement),y)}catch{return ni("there is an error with this statement. it is likely empty or has something invalid",y),new Pn(null)}case"IF_ELSE":try{return new T$(Se(y.condition),Se(y.statement),Se(y.alternative),y)}catch{return ni("there is an error with this statement. it is likely empty or has something invalid",y),new Pn(null)}case"ASSIGNMENT":try{return new y$(y,y.varType,y.name,Se(y.value),y)}catch(a){return ni("assignment error",y),console.error("assignment error: ",a),null}case"VARIABLE":try{return new w$(y,y.name,y)}catch{ni("assignment error",y);return}case"FOR":try{var $=Se(y.initialization),r=Se(y.condition),p=Se(y.incriment),m=Se(y.statement);return new I$($,r,p,m,y)}catch(a){return console.error(a),new Pn(null)}case"WHILE":try{var r=Se(y.condition),m=Se(y.statement);return new R$(r,m,y)}catch(a){return console.error(a),new Pn(null)}case"DO_WHILE":try{var r=Se(y.condition),m=Se(y.statement);return new C$(r,m,y)}catch(a){return console.error("An error occurred: empty statement",a),new Pn(null)}case"REPEAT_UNTIL":try{var r=Se(y.condition),m=Se(y.statement);return new k$(r,m,y)}catch(a){return console.error("An error occurred: empty statement",a),new Pn(null)}case"NOT":return new A$(Se(y.value),y);case"COMMENT":return new t$(y.value,y);case"SINGLE_LINE_COMMENT":return new e$(y.value,y);case"FUNCTION_ASSIGNMENT":var B=Se(y.contents);return new O$(y.returnType,y.name,y.params,B,y);case"FUNCTION_CALL":var P=[];return y.params.forEach(a=>{P.push(Se(a))}),new L$(y.name,P,y);case"RETURN":return new s$(Se(y.value),y);case"ARRAY":var P=[];return y.params.forEach(a=>{P.push(Se(a))}),new i$(P,y);case"ARRAY_REFERENCE":return new S$(y.name,Se(y.index),y);default:console.error(`I donot recognize this type: ${y.type}}`)}};class e${constructor($,r){this.jsonType="Praxly_single_line_comment",this.json=r,this.value=$}evaluate($){}}class t${constructor($,r){this.jsonType="Praxly_comment",this.json=r,this.value=$}evaluate($){}}class xt{constructor($,r){this.jsonType="Praxly_int",this.json=r,this.value=Math.floor($)}evaluate($){return this}}class Bt{constructor($,r){this.jsonType="Praxly_double",this.json=r,this.value=parseFloat($).toFixed(1)}evaluate($){return this}}class bt{constructor($,r){this.json=r,this.jsonType="Praxly_boolean",this.value=$}evaluate($){return this}}class $m{constructor($,r){this.value=$,this.json=r,this.jsonType="Praxly_String"}evaluate($){return this}}class Qt{constructor($,r){this.jsonType="Praxly_String",this.json=r,this.value=$}evaluate($){return this}}class i${constructor($,r){this.elements=$,this.blockjson=r,this.jsonType="Praxly_array"}evaluate($){return this}}class n${constructor($,r){this.json=r,this.expression=$}evaluate($){return W_(this.expression.evaluate($).value.toString()+"
"),null}}class s${constructor($,r){this.json=r,this.expression=$,this.isreturn=!0}evaluate($){throw new Lm(this.expression.evaluate($))}}class r${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){let r=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("ADD",p,r)){case"INT":return new xt(p.value+r.value);case"STRING":return new Qt(p.value+r.value);case"DOUBLE":return new Bt(p.value+r.value);case"BOOLEAN":return new bt(p.value+r.value)}}}class o${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){let r=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("SUBTRACT",p,r)){case"INT":return new xt(p.value-r.value);case"STRING":return new Qt(p.value-r.value);case"DOUBLE":return new Bt(p.value-r.value);case"BOOLEAN":return new bt(p.value-r.value)}}}class l${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){let r=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("MULTIPLY",p,r)){case"INT":return new xt(p.value*r.value);case"STRING":return new Qt(p.value*r.value);case"DOUBLE":return new Bt(p.value*r.value);case"BOOLEAN":return new bt(p.value*r.value)}}}class a${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){let r=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("DIVISION",p,r)){case"INT":return new xt(p.value/r.value);case"STRING":return new Qt(p.value/r.value);case"DOUBLE":return new Bt(p.value/r.value);case"BOOLEAN":return new bt(p.value/r.value)}}}class c${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){let r=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("MODULO",p,r)){case"INT":return new xt(p.value%r.value);case"STRING":return new Qt(p.value%r.value);case"DOUBLE":return new Bt(p.value%r.value);case"BOOLEAN":return new bt(p.value%r.value)}}}class h${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){let r=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("EXPONENT",p,r)){case"INT":return new xt(p.value**r.value);case"STRING":return new Qt(p.value**r.value);case"DOUBLE":return new Bt(p.value**r.value);case"BOOLEAN":return new bt(p.value**r.value)}}}class u${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){return new bt(this.a_operand.evaluate($).value&&this.b_operand.evaluate($).value)}}class d${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){return new bt(this.a_operand.evaluate($).value||this.b_operand.evaluate($).value)}}class p${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){return new bt(this.a_operand.evaluate($).value===this.b_operand.evaluate($).value)}}class g${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){return new bt(this.a_operand.evaluate($).value!=this.b_operand.evaluate($).value)}}class f${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){return new bt(this.a_operand.evaluate($).value>this.b_operand.evaluate($).value)}}class m${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){return new bt(this.a_operand.evaluate($).value=this.b_operand.evaluate($).value)}}class $${constructor($,r,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=r}evaluate($){return new bt(this.a_operand.evaluate($).value<=this.b_operand.evaluate($).value)}}class v${constructor($,r,p){this.json=p,this.condition=$,this.code=r}evaluate($){return this.condition.evaluate($).value&&this.code.evaluate($),"success"}}class T${constructor($,r,p,m){this.json=m,this.condition=$,this.code=r,this.alternitive=p}evaluate($){return this.condition.evaluate($).value?this.code.evaluate($):this.alternitive.evaluate($),"success"}}class Pn{constructor($){this.contents=$}evaluate($){try{return this.contents.evaluate($)}catch{return}}}class E${constructor($){this.codeBlock=$}evaluate(){return this.codeBlock.evaluate(Om.global)}}class b${constructor($){this.praxly_blocks=$,console.log(this.praxly_blocks)}evaluate($){for(let r=0;r=","GREATER_THAN_EQUAL"],["≠","NOT_EQUAL"],["<","LESS_THAN"],[">","GREATER_THAN"]]},{type:"input_dummy"},{type:"input_value",name:"B_OPERAND"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",tooltip:"",helpUrl:""},{type:"praxly_arithmetic_block",message0:"%1 %2 %3 %4",args0:[{type:"input_value",name:"A_OPERAND"},{type:"field_dropdown",name:"OPERATOR",options:[["+","ADD"],["-","SUBTRACT"],["*","MULTIPLY"],["/","DIVIDE"],["%","MOD"],["^","EXPONENT"]]},{type:"input_dummy"},{type:"input_value",name:"B_OPERAND"}],inputsInline:!0,output:null,style:"expression_blocks",tooltip:"",helpUrl:""},{type:"praxly_boolean_operators_block",message0:"%1 %2 %3 %4",args0:[{type:"input_value",name:"A_OPERAND",check:"Boolean"},{type:"field_dropdown",name:"OPERATOR",options:[["and","AND"],["or","OR"]]},{type:"input_dummy"},{type:"input_value",name:"B_OPERAND",check:"Boolean"}],inputsInline:!0,output:"Boolean",style:"logic_blocks",tooltip:"",helpUrl:""},{type:"praxly_comment_block",message0:"/* %1 %2 */",args0:[{type:"input_dummy"},{type:"field_input",name:"COMMENT",text:"comment"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"comment_blocks",tooltip:"",helpUrl:""},{type:"praxly_single_line_comment_block",message0:"// %1 %2",args0:[{type:"input_dummy"},{type:"field_input",name:"COMMENT",text:"comment"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"comment_blocks",tooltip:"",helpUrl:""},{type:"praxly_class_block",message0:"class %1 %2 end class",args0:[{type:"input_dummy"},{type:"input_statement",name:"class"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"class_blocks",tooltip:"",helpUrl:""},{type:"praxly_procedure_block",message0:"%1 %2 %3 ( %4 ) %5 %6 end %7",args0:[{type:"field_dropdown",name:"RETURNTYPE",options:[["int","int"],["boolean","boolean"],["double","double"],["char","char"],["String","String"],["float","float"],["short","short"]]},{type:"input_dummy"},{type:"field_input",name:"PROCEDURE_NAME",text:"procedureName"},{type:"input_value",name:"PARAMS",text:"params"},{type:"input_dummy"},{type:"input_statement",name:"CONTENTS"},{type:"field_input",name:"END_PROCEDURE_NAME",text:"procedureName"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"procedure_blocks",tooltip:"test",helpUrl:"",onchange:"updateProcedureName"},{type:"praxly_function_call_block",message0:"%1 (%2)",args0:[{type:"field_input",name:"PROCEDURE_NAME",text:"procedureName"},{type:"input_value",name:"PARAMS",text:"params"}],inputsInline:!0,output:null,style:"procedure_blocks",tooltip:"test",helpUrl:"",onchange:"updateProcedureName"},{type:"praxly_assignment_block",message0:"%1%2 ⬅ %3 %4",args0:[{type:"field_dropdown",name:"VARTYPE",options:[["int","int"],["boolean","boolean"],["double","double"],["char","char"],["String","String"],["float","float"],["short","short"]]},{type:"field_input",name:"VARIABLENAME",text:"VariableName"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_array_reference_reassignment_block",message0:"%1[%2]⬅%3 %4",args0:[{type:"field_input",name:"VARIABLENAME",text:"arrayName"},{type:"input_value",name:"INDEX"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_reassignment_block",message0:"%1⬅%2 %3",args0:[{type:"field_input",name:"VARIABLENAME",text:"VariableName"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_return_block",message0:"return %1",args0:[{type:"input_value",name:"EXPRESSION"}],inputsInline:!0,previousStatement:null,style:"procedure_blocks",tooltip:"",helpUrl:""},{type:"praxly_print_block",message0:"print %1 %2",args0:[{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],previousStatement:null,nextStatement:null,style:"procedure_blocks",tooltip:"",helpUrl:""},{type:"praxly_statement_block",message0:"%1",args0:[{type:"input_value",name:"EXPRESSION"}],previousStatement:null,nextStatement:null,style:"procedure_blocks",tooltip:"",helpUrl:""},{type:"praxly_literal_block",message0:"%1",args0:[{type:"field_input",name:"LITERAL",text:"value"}],output:null,style:"expression_blocks",tooltip:"",helpUrl:""},{type:"praxly_variable_block",message0:"%1",args0:[{type:"field_input",name:"LITERAL",text:"name"}],output:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_String_block",message0:'"%1"',args0:[{type:"field_input",name:"LITERAL",text:"String"}],output:null,style:"expression_blocks",tooltip:"",helpUrl:""},{type:"custom_operation_block",message0:"Custom Operation %1 %2",args0:[{type:"input_value",name:"input1",check:"Number",align:"RIGHT",defaultType:"math_number",defaultValue:5},{type:"input_value",name:"input2",check:"Number",align:"RIGHT",defaultType:"math_number",defaultValue:10}],output:"Number",colour:230,tooltip:"Perform custom operation",helpUrl:""},{type:"praxly_assignment_expression_block",message0:"%1%2 ⬅ %3 %4",args0:[{type:"field_dropdown",name:"VARTYPE",options:[["int","int"],["boolean","boolean"],["double","double"],["char","char"],["String","String"],["float","float"],["short","short"]]},{type:"field_input",name:"VARIABLENAME",text:"i"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,output:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_not_block",message0:"not %1 %2",args0:[{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],output:"Boolean",style:"logic_blocks",tooltip:"",helpUrl:""},{type:"praxly_reassignment_expression_block",message0:"%1⬅%2 %3",args0:[{type:"field_input",name:"VARIABLENAME",text:"i"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,output:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_parameter_block",message0:"%1 %2",args0:[{type:"field_image",src:"https://iconsplace.com/wp-content/uploads/_icons/ffffff/256/png/plus-icon-18-256.png",name:"PLUS_BUTTON",width:19,height:19,alt:"*"},{type:"field_image",src:"https://iconsplace.com/wp-content/uploads/_icons/ffffff/256/png/minus-icon-256.png",name:"MINUS_BUTTON",width:19,height:19,alt:"*"}],output:null,style:"parameter_blocks",tooltip:"",helpUrl:"",mutator:"praxly_arity",extensions:["addParams"],inputsInline:!0},{type:"praxly_singular_param_block",message0:"%1%2",args0:[{type:"field_dropdown",name:"VARTYPE",options:[["int","int"],["boolean","boolean"],["double","double"],["char","char"],["String","String"],["float","float"],["short","short"]]},{type:"field_input",name:"VARIABLENAME",text:"i"}],inputsInline:!0,output:null,style:"parameter_blocks",tooltip:"",helpUrl:""},{type:"praxly_array_assignment_block",message0:"%1[] %2 ⬅ {%3 %4}",args0:[{type:"field_dropdown",name:"VARTYPE",options:[["int","int"],["boolean","boolean"],["double","double"],["char","char"],["String","String"],["float","float"],["short","short"]]},{type:"field_input",name:"VARIABLENAME",text:"arrayName"},{type:"input_value",name:"EXPRESSION"},{type:"input_dummy"}],inputsInline:!0,previousStatement:null,nextStatement:null,style:"variable_blocks",tooltip:"",helpUrl:""},{type:"praxly_array_reference_block",message0:"%1[%2] %3",args0:[{type:"field_input",name:"VARIABLENAME",text:"arrayName"},{type:"input_value",name:"INDEX",text:"0"},{type:"input_dummy"}],inputsInline:!0,style:"variable_blocks",tooltip:"",helpUrl:"",output:null}])}function mm(T){return/^\d+$/.test(T)}const Q_=(T,$)=>{var s={type:"PROGRAM",blockID:"blocksRoot",value:$.codeBLockJsonBuilder(T.getTopBlocks()[0])};return s},q_=()=>{const T=[];return T.codeBLockJsonBuilder=$=>{var s={type:"CODEBLOCK",blockID:"blocks[]"},p=[];let m=$;for(;m.getNextBlock()!=null;)p.push(T[m.type](m)),m=m.getNextBlock();return p.push(T[m.type](m)),s.statements=p,s},T.praxly_arithmetic_block=$=>{const s=$.getChildren(!0),p=s[0],m=s[1],B={blockID:$.id,left:T[p.type](p),right:T[m.type](m)};return B.type=$.getFieldValue("OPERATOR"),B},T.praxly_print_block=$=>{const s=$.getInputTargetBlock("EXPRESSION");return{blockID:$.id,type:"PRINT",value:T[s.type](s)}},T.praxly_array_reference_block=$=>{var s=$.getInputTargetBlock("INDEX");return{blockID:$.id,type:"ARRAY_REFERENCE",name:$.getFieldValue("VARIABLENAME"),index:T[s.type](s)}},T.praxly_literal_block=$=>{const s=$.getFieldValue("LITERAL"),p={blockID:$.id,value:s};return s[0]==='"'&&s[s.length-1]==='"'?(p.type="STRING",p.value=s.slice(1,-1)):s.includes(".")?p.type="DOUBLE":mm(s)?p.type="INT":(p.type="VARIABLE",p.name=s),p},T.praxly_variable_block=$=>{const s=$.getFieldValue("LITERAL"),p={blockID:$.id,value:s};return s[0]==='"'&&s[s.length-1]==='"'?(p.type="STRING",p.value=s.slice(1,-1)):s.includes(".")?p.type="DOUBLE":mm(s)?p.type="INT":(p.type="VARIABLE",p.name=s),p},T.praxly_boolean_operators_block=$=>{const s=$.getChildren(!0),p=s[0],m=s[1],B={blockID:$.id,left:T[p.type](p),right:T[m.type](m)};return B.type=$.getFieldValue("OPERATOR"),B},T.praxly_compare_block=$=>{const s=$.getChildren(!0),p=s[0],m=s[1],B={blockID:$.id,left:T[p.type](p),right:T[m.type](m)};return B.type=$.getFieldValue("OPERATOR"),B},T.praxly_true_block=$=>({blockID:$.id,value:!0,type:"BOOLEAN"}),T.praxly_false_block=$=>({blockID:$.id,value:!1,type:"BOOLEAN"}),T.praxly_comment_block=$=>({blockID:$.id,value:$.getFieldValue("COMMENT"),type:"COMMENT"}),T.praxly_single_line_comment_block=$=>({blockID:$.id,value:$.getFieldValue("COMMENT"),type:"SINGLE_LINE_COMMENT"}),T.praxly_if_block=$=>{const s=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT");return{type:"IF",blockID:$.id,condition:T[s.type](s),statement:T.codeBLockJsonBuilder(p)}},T.praxly_if_else_block=$=>{const s=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT"),m=$.getInputTargetBlock("ALTERNATIVE");return{type:"IF_ELSE",blockID:$.id,condition:T[s.type](s),statement:T.codeBLockJsonBuilder(p),alternative:T.codeBLockJsonBuilder(m)}},T.praxly_assignment_block=$=>{var s=$.getFieldValue("VARTYPE");console.log(`field input is ${s}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=T[m.type](m);return{type:"ASSIGNMENT",name:p,value:B,blockID:$.id,varType:"Praxly_"+s}},T.praxly_array_assignment_block=$=>{var s=$.getFieldValue("VARTYPE");console.log(`field input is ${s}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=m.getChildren(!0),P=[];return B.forEach(C=>{P.push(T[C.type](C))}),{type:"ARRAY_ASSIGNMENT",name:p,value:{blockID:m.id,params:P,type:"ARRAY"},blockID:$.id,varType:"Praxly_"+s}},T.praxly_reassignment_block=$=>{var s=$.getFieldValue("VARTYPE");console.log(`field input is ${s}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=T[m.type](m);return{type:"ASSIGNMENT",name:p,value:B,blockID:$.id,varType:"reassignment"}},T.praxly_array_reference_reassignment_block=$=>{var s=$.getFieldValue("VARIABLENAME"),p=$.getInputTargetBlock("EXPRESSION"),m=$.getInputTargetBlock("INDEX"),B=T[p.type](p),P=T[m.type](m);return{type:"ARRAY_REFERENCE_ASSIGNMENT",name:s,index:P,value:B,blockID:$.id}},T.praxly_assignment_expression_block=$=>{var s=$.getFieldValue("VARTYPE");console.log(`field input is ${s}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=T[m.type](m);return{type:"ASSIGNMENT",name:p,value:B,blockID:$.id,varType:"Praxly_"+s}},T.praxly_reassignment_expression_block=$=>{var s=$.getFieldValue("VARTYPE");console.log(`field input is ${s}`);var p=$.getFieldValue("VARIABLENAME"),m=$.getInputTargetBlock("EXPRESSION"),B=T[m.type](m);return{type:"ASSIGNMENT",name:p,value:B,blockID:$.id,varType:"reassignment"}},T.praxly_while_loop_block=$=>{const s=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT");return{type:"WHILE",blockID:$.id,condition:T[s.type](s),statement:T.codeBLockJsonBuilder(p)}},T.praxly_do_while_loop_block=$=>{const s=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT");return{type:"DO_WHILE",blockID:$.id,condition:T[s.type](s),statement:T.codeBLockJsonBuilder(p)}},T.praxly_repeat_until_loop_block=$=>{const s=$.getInputTargetBlock("CONDITION"),p=$.getInputTargetBlock("STATEMENT");return{type:"REPEAT_UNTIL",blockID:$.id,condition:T[s.type](s),statement:T.codeBLockJsonBuilder(p)}},T.praxly_not_block=$=>{const s=$.getInputTargetBlock("EXPRESSION");return{blockID:$.id,type:"NOT",value:T[s.type](s)}},T.praxly_for_loop_block=$=>{var s=$.getInputTargetBlock("INITIALIZATION"),p=$.getInputTargetBlock("CONDITION"),m=$.getInputTargetBlock("REASSIGNMENT");const B=$.getInputTargetBlock("CODEBLOCK");return{type:"FOR",blockID:$.id,initialization:T[s.type](s),statement:T.codeBLockJsonBuilder(B),incriment:T[m.type](m),condition:T[p.type](p)}},T.praxly_procedure_block=$=>{var s=$.getFieldValue("RETURNTYPE"),p=$.getInputTargetBlock("PARAMS"),m=p.getChildren(!0),B=[];m.forEach(f=>{var a=[];a[0]=f.getFieldValue("VARTYPE"),a[1]=f.getFieldValue("VARIABLENAME"),B.push(a)});var P=$.getFieldValue("PROCEDURE_NAME");const C=$.getInputTargetBlock("CONTENTS");return $.setFieldValue(P,"END_PROCEDURE_NAME"),{type:"FUNCTION_ASSIGNMENT",name:P,params:B,returnType:s,contents:T.codeBLockJsonBuilder(C),blockID:$.id}},T.praxly_function_call_block=$=>{var s=$.getFieldValue("PROCEDURE_NAME"),p=$.getInputTargetBlock("PARAMS"),m=p.getChildren(!0),B=[];return m.forEach(P=>{B.push(T[P.type](P))}),{blockID:$.id,type:"FUNCTION_CALL",name:s,params:B}},T.praxly_return_block=$=>{const s=$.getInputTargetBlock("EXPRESSION");return{blockID:$.id,type:"RETURN",value:T[s.type](s)}},T};var km={};class Om extends Error{constructor($){super(`attempting to return. this should return ${$}`),this.name=this.constructor.name,this.errorData=$}}const Se=T=>{if(typeof T>"u"||typeof T.type>"u")return console.error("error constructing the tree: reached an invalid branch that is either undefined or has an undefined type"),new Tl;switch(console.log(T.type),T.type){case"INT":return new xt(T.value,T);case"STRING":return new qt(T.value,T);case"BOOLEAN":return new bt(T.value,T);case"DOUBLE":return new Bt(T.value,T);case"ADD":return new o$(Se(T.left),Se(T.right),T);case"SUBTRACT":return new l$(Se(T.left),Se(T.right),T);case"MULTIPLY":return new a$(Se(T.left),Se(T.right),T);case"DIVIDE":return new c$(Se(T.left),Se(T.right),T);case"EXPONENT":return new u$(Se(T.left),Se(T.right),T);case"MOD":return new h$(Se(T.left),Se(T.right),T);case"AND":return new d$(Se(T.left),Se(T.right),T);case"OR":return new p$(Se(T.left),Se(T.right),T);case"EQUALS":return new g$(Se(T.left),Se(T.right),T);case"LESS_THAN_EQUAL":return new v$(Se(T.left),Se(T.right),T);case"GREATER_THAN_EQUAL":return new $$(Se(T.left),Se(T.right),T);case"GREATER_THAN":return new m$(Se(T.left),Se(T.right),T);case"LESS_THAN":return new _$(Se(T.left),Se(T.right),T);case"NOT_EQUAL":return new f$(Se(T.left),Se(T.right),T);case"PRINT":return new s$(Se(T.value),T);case"CODEBLOCK":let f=T.statements.map(a=>{try{return Se(a)}catch{return new $m(T)}});return new y$(f);case"PROGRAM":return km={global:{variableList:{},functionList:{}}},new b$(Se(T.value));case"STATEMENT":try{return new Fn(Se(T.value),T)}catch{return new $m(T)}case"IF":try{return new T$(Se(T.condition),Se(T.statement),T)}catch{return Xt("there is an error with this statement. it is likely empty or has something invalid",T),new Fn(null)}case"IF_ELSE":try{return new E$(Se(T.condition),Se(T.statement),Se(T.alternative),T)}catch{return Xt("there is an error with this statement. it is likely empty or has something invalid",T),new Fn(null)}case"ASSIGNMENT":try{return new w$(T,T.varType,T.name,Se(T.value),T)}catch(a){return Xt("assignment error",T),console.error("assignment error: ",a),null}case"ARRAY_ASSIGNMENT":try{return new S$(T,T.varType,T.name,Se(T.value),T)}catch(a){return Xt("assignment error",T),console.error("assignment error: ",a),null}case"VARIABLE":try{return new I$(T,T.name,T)}catch{Xt("assignment error",T);return}case"FOR":try{var $=Se(T.initialization),s=Se(T.condition),p=Se(T.incriment),m=Se(T.statement);return new C$($,s,p,m,T)}catch(a){return console.error(a),new Fn(null)}case"WHILE":try{var s=Se(T.condition),m=Se(T.statement);return new A$(s,m,T)}catch(a){return console.error(a),new Fn(null)}case"DO_WHILE":try{var s=Se(T.condition),m=Se(T.statement);return new k$(s,m,T)}catch(a){return console.error("An error occurred: empty statement",a),new Fn(null)}case"REPEAT_UNTIL":try{var s=Se(T.condition),m=Se(T.statement);return new O$(s,m,T)}catch(a){return console.error("An error occurred: empty statement",a),new Fn(null)}case"NOT":return new L$(Se(T.value),T);case"COMMENT":return new i$(T.value,T);case"SINGLE_LINE_COMMENT":return new t$(T.value,T);case"FUNCTION_ASSIGNMENT":var B=Se(T.contents);return new M$(T.returnType,T.name,T.params,B,T);case"FUNCTION_CALL":var P=[];return T.params.forEach(a=>{P.push(Se(a))}),new N$(T.name,P,T);case"RETURN":return new r$(Se(T.value),T);case"ARRAY":var P=[];return T.params.forEach(a=>{P.push(Se(a))}),new n$(P,T);case"ARRAY_REFERENCE":return new R$(T.name,Se(T.index),T);case"ARRAY_REFERENCE_ASSIGNMENT":return new e$(T.name,Se(T.index),Se(T.value),T);default:console.error(`I donot recognize this type: ${T.type}}`)}};class e${constructor($,s,p,m){this.json=m,this.name=$,this.value=p,this.index=s}evaluate($){$.variableList[this.name].elements[this.index.evaluate($).value]=this.value.evaluate($)}}class t${constructor($,s){this.jsonType="Praxly_single_line_comment",this.json=s,this.value=$}evaluate($){}}class i${constructor($,s){this.jsonType="Praxly_comment",this.json=s,this.value=$}evaluate($){}}class xt{constructor($,s){this.jsonType="Praxly_int",this.json=s,this.value=Math.floor($)}evaluate($){return this}}class Bt{constructor($,s){this.jsonType="Praxly_double",this.json=s,this.value=parseFloat($).toFixed(1)}evaluate($){return this}}class bt{constructor($,s){this.json=s,this.jsonType="Praxly_boolean",this.value=$}evaluate($){return this}}class _m{constructor($,s){this.value=$,this.json=s,this.jsonType="Praxly_String"}evaluate($){return this}}class qt{constructor($,s){this.jsonType="Praxly_String",this.json=s,this.value=$}evaluate($){return this}}class n${constructor($,s){this.elements=$,this.blockjson=s,this.jsonType="Praxly_array"}evaluate($){return this}}class s${constructor($,s){this.json=s,this.expression=$}evaluate($){return W_(this.expression.evaluate($).value.toString()+"
"),null}}class r${constructor($,s){this.json=s,this.expression=$,this.isreturn=!0}evaluate($){throw new Om(this.expression.evaluate($))}}class o${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){let s=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("ADD",p,s)){case"INT":return new xt(p.value+s.value);case"STRING":return new qt(p.value+s.value);case"DOUBLE":return new Bt(p.value+s.value);case"BOOLEAN":return new bt(p.value+s.value)}}}class l${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){let s=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("SUBTRACT",p,s)){case"INT":return new xt(p.value-s.value);case"STRING":return new qt(p.value-s.value);case"DOUBLE":return new Bt(p.value-s.value);case"BOOLEAN":return new bt(p.value-s.value)}}}class a${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){let s=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("MULTIPLY",p,s)){case"INT":return new xt(p.value*s.value);case"STRING":return new qt(p.value*s.value);case"DOUBLE":return new Bt(p.value*s.value);case"BOOLEAN":return new bt(p.value*s.value)}}}class c${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){let s=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("DIVISION",p,s)){case"INT":return new xt(p.value/s.value);case"STRING":return new qt(p.value/s.value);case"DOUBLE":return new Bt(p.value/s.value);case"BOOLEAN":return new bt(p.value/s.value)}}}class h${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){let s=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("MODULO",p,s)){case"INT":return new xt(p.value%s.value);case"STRING":return new qt(p.value%s.value);case"DOUBLE":return new Bt(p.value%s.value);case"BOOLEAN":return new bt(p.value%s.value)}}}class u${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){let s=this.b_operand.evaluate($),p=this.a_operand.evaluate($);switch(Os("EXPONENT",p,s)){case"INT":return new xt(p.value**s.value);case"STRING":return new qt(p.value**s.value);case"DOUBLE":return new Bt(p.value**s.value);case"BOOLEAN":return new bt(p.value**s.value)}}}class d${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){return new bt(this.a_operand.evaluate($).value&&this.b_operand.evaluate($).value)}}class p${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){return new bt(this.a_operand.evaluate($).value||this.b_operand.evaluate($).value)}}class g${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){return new bt(this.a_operand.evaluate($).value===this.b_operand.evaluate($).value)}}class f${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){return new bt(this.a_operand.evaluate($).value!=this.b_operand.evaluate($).value)}}class m${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){return new bt(this.a_operand.evaluate($).value>this.b_operand.evaluate($).value)}}class _${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){return new bt(this.a_operand.evaluate($).value=this.b_operand.evaluate($).value)}}class v${constructor($,s,p){qe(this,"a_operand");qe(this,"b_operand");this.json=p,this.a_operand=$,this.b_operand=s}evaluate($){return new bt(this.a_operand.evaluate($).value<=this.b_operand.evaluate($).value)}}class T${constructor($,s,p){this.json=p,this.condition=$,this.code=s}evaluate($){return this.condition.evaluate($).value&&this.code.evaluate($),"success"}}class E${constructor($,s,p,m){this.json=m,this.condition=$,this.code=s,this.alternitive=p}evaluate($){return this.condition.evaluate($).value?this.code.evaluate($):this.alternitive.evaluate($),"success"}}class Fn{constructor($){this.contents=$}evaluate($){try{return this.contents.evaluate($)}catch{return}}}class b${constructor($){this.codeBlock=$}evaluate(){return this.codeBlock.evaluate(km.global)}}class y${constructor($){this.praxly_blocks=$,console.log(this.praxly_blocks)}evaluate($){for(let s=0;s{bl?tv():ev()});Z_();Rt.addChangeListener(_l);et.addEventListener("input",Vr);El.addEventListener("mousedown",function(y){Tu=!0,document.addEventListener("mousemove",Dm)});document.addEventListener("mouseup",function(y){Tu=!1,document.removeEventListener("mousemove",Dm),ri.svgResize(Rt),et.resize()});Nm.addEventListener("click",function(){var y="pseudocode.html";window.open(y,"_blank")});X$.addEventListener("click",function(){window.open("BugsList.html","_blank")});Y$.addEventListener("click",function(){window.open("changelog.html","_blank")});z$.addEventListener("click",function(){window.open("features.html","_blank")});J$.addEventListener("click",function(){window.open("https://github.com/Praxly/praxly.github.io","_blank")});Z$.addEventListener("click",function(){window.open("https://sauppb.github.io/website/")});Wr.addEventListener("click",()=>{Rt.removeChangeListener(_l),Rt.addChangeListener(_l)});zr.addEventListener("click",()=>{et.removeEventListener("input",Vr),et.addEventListener("input",Vr)});var Q$=document.getElementsByClassName("close")[0];W$.onclick=function(){fl.style.display="block"};Nm.onclick=function(){ml.style.display="block"};Q$.onclick=function(){fl.style.display="none",ml.style.display="none"};window.onclick=function(y){(y.target==fl||y.target==ml)&&(fl.style.display="none",ml.style.display="none")};function q$(){Cm(),Ji===null&&alert(`there is nothing to run :( - try typing some code or dragging some blocks first.`),console.log(Ji);const y=Se(Ji);console.log(y),y.evaluate(),Ur.length>0?(pl.innerHTML=Ur,pl.style.color="#ff0000"):(pl.innerHTML=$l,pl.style.color=bl?"#FFFFFF":"#000000"),et.session.setAnnotations(vl),km(Rt)}function Vr(){Rt.removeChangeListener(_l),Cm(),Ji=X_(),Rt.clear(),Ze(Rt,Ji),Rt.render(),et.session.setAnnotations(vl),km(Rt)}function _l(){et.removeEventListener("input",Vr),Ji=Q_(Rt,G$),console.log(Ji);const y=we(Ji,0,0);et.setValue(y,-1)}function Dm(y){if(!Tu)return;const $=document.querySelector("main").offsetWidth,p=y.pageX/$*100,m=100-p;Wr.style.flex=p,zr.style.flex=m}var xm=document.getElementById("ToolboxCss");function ev(){bl=!0,Rt.setTheme(U_),et.setTheme("ace/theme/twilight");var y=document.body;y.style.backgroundColor="black";for(var $=document.querySelectorAll(".output, .error, .nav-bar"),r=0;r<$.length;r++)$[r].style.backgroundColor="#303030",$[r].style.color="white";xm.href="darkThemeToolbox.css"}function tv(){bl=!1,Rt.setTheme(wm),et.setTheme("ace/theme/katzenmilch");var y=document.body;y.style.backgroundColor="white";for(var $=document.querySelectorAll(".output, .error, .nav-bar"),r=0;r<$.length;r++)$[r].style.backgroundColor="#e3e6e4",$[r].style.color="black";xm.href="toolbox.css"}j$.addEventListener("keydown",function(y){if((y.key==="s"||y.key==="S")&&(y.ctrlKey||y.metaKey)){y.preventDefault();const $=document.querySelector(".output");$.innerHTML="";const r=Se(Ji);r.evaluate(),$.innerHTML=$l,stdError.innerHTML=Ur,console.log(r)}});H$.addEventListener("click",Mm);P$(Vr);const Bm=document.getElementById("tab1_button"),iv=document.getElementById("tab2_button"),nv=document.getElementById("tab3_button");nv.addEventListener("click",function(y){El.style.display="none",zr.style.display="none",Wr.style.display="block",ri.svgResize(Rt),et.resize()});iv.addEventListener("click",function(y){El.style.display="none",Wr.style.display="none",zr.style.display="block",ri.svgResize(Rt),et.resize()});Bm.addEventListener("click",function(y){El.style.display="block",Wr.style.display="block",zr.style.display="block",ri.svgResize(Rt),et.resize()});Bm.click();function sv(){const y=vu.split("##"),$={};for(let p=1;p= 0 and arr[j] > key) + arr[j + 1] = arr[j] + j = j - 1 + end while + arr[j + 1] = key + end for +end insertionSort + +// Function call +insertionSort(10) + +// Print the sorted array +for (int i = 0; i < 10; i = i + 1) + print arr[i] +end for + +##Factorial +##// this function returns the factorial of a number. +int fact(int n) + if (n < 2) + return n + end if + return n * fact(n - 1) +end fact +// try printing different numbers to test your code! +print fact(5) +different numbers to test your code! +print fact(5) + +##Fibonacci +##int fibonacci(int n) +if (n <= 1) + return n +else + return fibonacci(n - 1) + fibonacci(n - 2) +end if +end fibonacci +print fibonacci(10) + + + +`,V$=q_(),Rt=ri.inject("blocklyDiv",{toolbox:H_,horizontalLayout:!1,toolboxPosition:"start",theme:ym,zoom:{controls:!0,wheel:!0,startScale:1,maxScale:3,minScale:.3,scaleSpeed:1.2,pinch:!0},renderer:"zelos"}),W$=document.getElementById("runButton"),z$=document.getElementById("share"),X$=document.getElementById("darkMode"),Y$=document.getElementById("help"),Mm=document.getElementById("reference"),El=document.querySelector(".resizeBar"),Wr=document.querySelector("#blocklyDiv"),zr=document.querySelector("#aceCode"),pl=document.querySelector(".output");var fl=document.getElementById("myModal"),ml=document.getElementById("manual");const K$=document.getElementById("FeaturesButton"),j$=document.getElementById("BugButton"),J$=document.getElementById("ChangelogButton"),Z$=document.getElementById("exampleTable"),Q$=et.container,q$=document.getElementById("GitHubButton"),ev=document.getElementById("AboutButton");var Ji=null;let bl=!1,vu=!1;W$.addEventListener("mouseup",iv);X$.addEventListener("click",()=>{bl?xm():nv()});Z_();Rt.addChangeListener(_l);et.addEventListener("input",Vr);El.addEventListener("mousedown",function(T){vu=!0,document.addEventListener("mousemove",Nm)});document.addEventListener("mouseup",function(T){vu=!1,document.removeEventListener("mousemove",Nm),ri.svgResize(Rt),et.resize()});Mm.addEventListener("click",function(){var T="pseudocode.html";window.open(T,"_blank")});j$.addEventListener("click",function(){window.open("BugsList.html","_blank")});J$.addEventListener("click",function(){window.open("changelog.html","_blank")});K$.addEventListener("click",function(){window.open("features.html","_blank")});q$.addEventListener("click",function(){window.open("https://github.com/Praxly/praxly.github.io","_blank")});ev.addEventListener("click",function(){window.open("https://sauppb.github.io/website/")});Wr.addEventListener("click",()=>{Rt.removeChangeListener(_l),Rt.addChangeListener(_l)});zr.addEventListener("click",()=>{et.removeEventListener("input",Vr),et.addEventListener("input",Vr)});var tv=document.getElementsByClassName("close")[0];Y$.onclick=function(){xm(),fl.style.display="block"};Mm.onclick=function(){ml.style.display="block"};tv.onclick=function(){fl.style.display="none",ml.style.display="none"};window.onclick=function(T){(T.target==fl||T.target==ml)&&(fl.style.display="none",ml.style.display="none")};function iv(){Rm(),Ji===null&&alert(`there is nothing to run :( + try typing some code or dragging some blocks first.`),console.log(Ji);const T=Se(Ji);console.log(T),T.evaluate(),Ur.length>0?(pl.innerHTML=Ur,pl.style.color="#ff0000"):(pl.innerHTML=$l,pl.style.color=bl?"#FFFFFF":"#000000"),et.session.setAnnotations(vl),Cm(Rt)}function Vr(){Rt.removeChangeListener(_l),Rm(),Ji=X_(),Rt.clear(),He(Rt,Ji),Rt.render(),et.session.setAnnotations(vl),Cm(Rt)}function _l(){et.removeEventListener("input",Vr),Ji=Q_(Rt,V$),console.log(Ji);const T=we(Ji,0,0);et.setValue(T,-1)}function Nm(T){if(!vu)return;const $=document.querySelector("main").offsetWidth,p=T.pageX/$*100,m=100-p;Wr.style.flex=p,zr.style.flex=m}var Dm=document.getElementById("ToolboxCss");function nv(){bl=!0,Rt.setTheme(U_),et.setTheme("ace/theme/twilight");var T=document.body;T.style.backgroundColor="black";for(var $=document.querySelectorAll(".output, .error, #secondary_bar, example_links, #exampleTable"),s=0;s<$.length;s++)$[s].style.backgroundColor="#303030",$[s].style.color="white";Dm.href="darkThemeToolbox.css"}function xm(){bl=!1,Rt.setTheme(ym),et.setTheme("ace/theme/katzenmilch");var T=document.body;T.style.backgroundColor="white";for(var $=document.querySelectorAll(".output, .error, #secondary_bar, example_links, #exampleTable"),s=0;s<$.length;s++)$[s].style.backgroundColor="#e3e6e4",$[s].style.color="black";Dm.href="toolbox.css"}Q$.addEventListener("keydown",function(T){if((T.key==="s"||T.key==="S")&&(T.ctrlKey||T.metaKey)){T.preventDefault();const $=document.querySelector(".output");$.innerHTML="";const s=Se(Ji);s.evaluate(),$.innerHTML=$l,stdError.innerHTML=Ur,console.log(s)}});z$.addEventListener("click",Lm);G$(Vr);const Bm=document.getElementById("tab1_button"),sv=document.getElementById("tab2_button"),rv=document.getElementById("tab3_button");rv.addEventListener("click",function(T){El.style.display="none",zr.style.display="none",Wr.style.display="block",ri.svgResize(Rt),et.resize()});sv.addEventListener("click",function(T){El.style.display="none",Wr.style.display="none",zr.style.display="block",ri.svgResize(Rt),et.resize()});Bm.addEventListener("click",function(T){El.style.display="block",Wr.style.display="block",zr.style.display="block",ri.svgResize(Rt),et.resize()});Bm.click();function ov(){const T=H$.split("##"),$={};for(let p=1;pChangelog
    - +
  • - Week of May 15, 2023: + Week of August 27th, 2023:
      -
    • NPM Project setup
    • -
    • Initial setup and dive in to Blockly
    • -
    • Working on setting up prototype blocks
    • -
    • Creating sample toolbox categories
    • -
    • +
    • tab feature is a work in progress
    • +
    • New Manual feature allows users to read the official documentation that I developed this language for
    • +
    • LOTS of fixes to the datatypes. Turns out only 2 of them were working before today.
  • - Week of May 22, 2023: + Week of July 17th, 2023:
      -
    • created block library
    • -
    • imported the text editor
    • -
    • made a function that builds the AST
    • -
    • Designed the exterior to include the code editor and output
    • -
    • Successfully supported running print blocks
    • -
    • Arithmetic operator support
    • -
    • Added support for running comparison blocks
    • -
    • The parser now works
    • -
    • Dark theme fully supported
    • -
    • +
    • Added support for function calls as an expression
    • +
    • Added support for the correct return statements
    • +
    • Functions now work again on the text side
    • +
    • Working on fixing the functions after breaking them
    • +
    • Discovered a bug where for loops don't run correctly in the website
    • +
    • Error messages are working on the text side
    • +
    • Properly displayed the error messages in the console
    • +
    • Added the red squiggly line for error messages
  • -
  • - Week of May 29th, 2023: + Week of July 10th, 2023:
      -
    • Generated and ran blocks and text live with updates
    • -
    • Completed the multiple statement parsing on both text and blocks
    • -
    • Fixed the blocks to code generation to support if statements
    • -
    • Redid a lot of the interior to make it easier for 'blocks' of code
    • -
    • Nested statements fixed
    • -
    • +
    • began Error messages
    • +
    • Lots of small cosmetic upgrades
    • +
    • Discovered a bug where for loops don't run correctly in the website
    • +
    • Fixed the issues where the menu was invisible
    • +
    • Made a features page
    • +
    • Fixed functions that have separate scopes and parameters
  • - Week of June 5th, 2023: + Week of July 3rd, 2023:
      -
    • Fixed the blocks to code generation to support if statements
    • -
    • Redid a lot of the interior to make it easier for 'blocks' of code
    • -
    • Updated the canonical tree so that blcoks are generated efficiently
    • +
    • +
    • fixed issue with the share url not working
    • +
    • play button
    • +
    • added features list
    • +
    • conceptualized scopes
  • - Week of June 12th, 2023: + Week of June 26th, 2023:
      -
    • Implimented Variable assignment
    • -
    • Added loops
    • +
    • +
    • added comment blocks
    • +
    • stored drafts in localStorage (no load function yet)
    • +
    • added the share button
    • +
    • Deployed the website
    • +
    • fixed the complex error tracking for indexes
    • +
    • started functions, but Didnt finish yet
  • Week of June 19th, 2023:
      -
    • Added Not block
    • -
    • merged the seperate trees
    • -
    • updated block locations when blocks are genereated
    • -
    • Started the error messages for basic errors
    • +
    • Started the error messages for basic errors
    • +
    • updated block locations when blocks are genereated
    • +
    • merged the seperate trees
    • +
    • Added Not block
  • - Week of June 26th, 2023: + Week of June 12th, 2023:
      -
    • started functions, but Didnt finish yet
    • -
    • fixed the complex error tracking for indexes
    • -
    • Deployed the website
    • -
    • added the share button
    • -
    • stored drafts in localStorage (no load function yet)
    • -
    • added comment blocks
    • -
    • +
    • Added loops
    • +
    • Implimented Variable assignment
  • - Week of July 3rd, 2023: + Week of June 5th, 2023:
      -
    • conceptualized scopes
    • -
    • added features list
    • -
    • play button
    • -
    • fixed issue with the share url not working
    • -
    • +
    • Updated the canonical tree so that blcoks are generated efficiently
    • +
    • Redid a lot of the interior to make it easier for 'blocks' of code
    • +
    • Fixed the blocks to code generation to support if statements
  • - Week of July 10th, 2023: + Week of May 29th, 2023:
      -
    • Fixed functions that have separate scopes and parameters
    • -
    • Made a features page
    • -
    • Fixed the issues where the menu was invisible
    • -
    • Discovered a bug where for loops don't run correctly in the website
    • -
    • Lots of small cosmetic upgrades
    • -
    • began Error messages
    • +
    • +
    • Nested statements fixed
    • +
    • Redid a lot of the interior to make it easier for 'blocks' of code
    • +
    • Fixed the blocks to code generation to support if statements
    • +
    • Generated and ran blocks and text live with updates
    • +
    • Completed the multiple statement parsing on both text and blocks
  • - Week of July 17th, 2023: + Week of May 22, 2023:
      -
    • Added the red squiggly line for error messages
    • -
    • Properly displayed the error messages in the console
    • -
    • Error messages are working on the text side
    • -
    • Discovered a bug where for loops don't run correctly in the website
    • -
    • Working on fixing the functions after breaking them
    • -
    • Functions now work again on the text side
    • -
    • Added support for the correct return statements
    • -
    • Added support for function calls as an expression
    • +
    • +
    • Dark theme fully supported
    • +
    • The parser now works
    • +
    • Added support for running comparison blocks
    • +
    • Arithmetic operator support
    • +
    • Successfully supported running print blocks
    • +
    • Designed the exterior to include the code editor and output
    • +
    • made a function that builds the AST
    • +
    • imported the text editor
    • +
    • created block library
  • - Week of August 27th, 2023: + Week of May 15, 2023:
      -
    • LOTS of fixes to the datatypes. Turns out only 2 of them were working before today.
    • -
    • New Manual feature allows users to read the official documentation that I developed this language for
    • -
    • tab feature is a work in progress
    • +
    • +
    • Creating sample toolbox categories
    • +
    • Working on setting up prototype blocks
    • +
    • Initial setup and dive in to Blockly
    • +
    • NPM Project setup
- diff --git a/features.html b/features.html index 3f7df77..3756af7 100644 --- a/features.html +++ b/features.html @@ -123,6 +123,14 @@
The following are features that are considered to be working:
Feature Name Feature Description + + Arrays + 1d arrays are here! + + + Example Code + have links to example code with explanations of how it works + Manual button for referencing the documentation @@ -196,14 +204,6 @@
The following are features that are planned for the future:
Classes Object oriented programming will be quite difficult. Inheritance will also be tricky. - - Arrays - Arrays coming soon! This will likely not be a feature until Classes are finished. - - - Example Code - have links to example code with explanations of how it works - Help Menu A tutorial on what Praxly is and how to use it. diff --git a/index.html b/index.html index aba4cf9..17a71ce 100644 --- a/index.html +++ b/index.html @@ -16,12 +16,11 @@ background-color: #ffffff; } - .output, - .error { + .output { box-sizing: border-box; background: #e3e6e4; margin: 10px; - height: 10vh; + height: 15vh; font-size: large; border-radius: 10px; overflow: auto; /* Add this */ @@ -56,8 +55,8 @@ display: flex; justify-content: space-between; align-items: center; - padding: 10px; - background-color: #f2f2f2; + padding: 5px; + background-color:goldenrod } .nav-bar img { @@ -318,13 +317,16 @@
URL copied to clipboard
- - + +