diff --git a/js/core/jseden.min.js b/js/core/jseden.min.js index 291ab09b9..7b1db3811 100644 --- a/js/core/jseden.min.js +++ b/js/core/jseden.min.js @@ -1,9 +1,9 @@ function noop(){}function get_time_diff(a){var b=1e3*a,c=Date.now(),d=new Date,e=6e4*d.getTimezoneOffset();if(b-=e,isNaN(b))return"";if(b5)return new Date(b).toDateString();var i="";if(g>0)i+=g,i+=g>1?" days ago":" day ago";else if(h.getUTCHours()>0){var j=h.getUTCHours();i+=j,i+=j>1?" hours ago":" hour ago"}else{var k=h.getUTCMinutes();if(k>0)i+=k,i+=k>1?" minutes ago":" minute ago";else{var l=h.getUTCSeconds();i+=l,i+=" seconds ago"}}return i}function generateTimeStamp(a){for(var b,c=/(\d*)(minutes|minute|min|hours|hour|days|day|weeks|week|months|month|mon|years|year|Quarters|Quarter|seconds|second|sec|s|m|h|d|M|y|Y|Q|ms|w)/g,d=0;null!==(b=c.exec(a));)switch(console.log("Reltime:",b),b[2]){case"second":case"seconds":case"s":d+=1e3*parseInt(b[1]);break;case"minute":case"minutes":case"m":d+=6e4*parseInt(b[1]);break;case"hour":case"hours":case"h":d+=36e5*parseInt(b[1]);break;case"days":case"d":d+=36e5*parseInt(b[1])*24}return d}function hashCode(a){var b=0;if(0==a.length)return b;for(i=0;i1?eden.root.lookup("jseden_url_"+x).assign(urlparams[x],eden.root.scope,Symbol.localJSAgent):eden.root.lookup("jseden_url_"+x).assign(urlparams[x][0],eden.root.scope,Symbol.localJSAgent);""==lang&&(lang="en");var plugins,defaultPlugins=["Canvas2D","DependencyMap","HTMLContent","PluginManager","ScriptInput","SymbolLookUpTable","SymbolViewer","Debugger","VersionViewer"];if(""==pluginsStr)plugins=defaultPlugins;else{var includeDefaultPlugins=" "==pluginsStr[0];includeDefaultPlugins&&(pluginsStr=pluginsStr.slice(1)),plugins=pluginsStr.split(","),includeDefaultPlugins&&(plugins=plugins.concat(defaultPlugins)),""!=views&&"default"!=views||(plugins.push("Canvas2D"),plugins.push("ScriptInput"))}$(document).ready(function(){function invalidVersion(a){$(".loadmessage").html(a)}var browser=$.browser,bversion=browser.version.split(".");bversion=parseInt(bversion[0]),browser.msie?bversion<13&&invalidVersion("Microsoft Internet Explorer is not supported, use Edge, Firefox or Chrome."):browser.mozilla?bversion<29&&invalidVersion("Please upgrade your version of Firefox/Mozilla."):browser.webkit&&!browser.chrome?invalidVersion("Your browser is not supported by JS-Eden, please use Edge, Firefox or Chrome."):browser.chrome?bversion<39&&invalidVersion("Please upgrade your version of Chrome"):invalidVersion(browser.opera?"Opera is not supported, use Chrome or Firefox.":"Your browser is not supported by JS-Eden, use Firefox or Chrome."),document.addEventListener("touchstart",touchHandler,!0),document.addEventListener("touchmove",touchHandler,!0),document.addEventListener("touchend",touchHandler,!0),document.addEventListener("touchcancel",touchHandler,!0),edenUI=new EdenUI(eden),edenUI.scrollBarSize2=window.innerHeight-$(window).height(),Eden.Project.init(),$.ajax({url:"version.json",dataType:"json",success:function(a){a.tag&&(document.title=document.title+" "+a.tag);var b=a.tag.slice(1).split("."),c=b[2].split("-");eden.root.lookup("jseden_version_major").assign(parseInt(b[0]),eden.root.scope,Symbol.defaultAgent),eden.root.lookup("jseden_version_minor").assign(parseInt(b[1]),eden.root.scope,Symbol.defaultAgent),eden.root.lookup("jseden_version_patch").assign(parseInt(c[0]),eden.root.scope,Symbol.defaultAgent),eden.root.lookup("jseden_version_commit").assign(parseInt(c[1]),eden.root.scope,Symbol.defaultAgent),eden.root.lookup("jseden_version_name").assign(a.tag,eden.root.scope,Symbol.defaultAgent),eden.root.lookup("jseden_version_sha").assign(a.sha,eden.root.scope,Symbol.defaultAgent)},cache:!1}),$(document).on("keydown",null,"ctrl+m",function(){edenUI.cycleNextView()}).on("keyup",null,"ctrl",function(){edenUI.stopViewCycling()}).on("keydown",null,"backspace",function(a){var b=a.target,c=b.tagName.toUpperCase();"INPUT"==c||"TEXTAREA"==c||b.isContentEditable||a.preventDefault()}),"false"!=edenUI.getOptionValue("optConfirmUnload")&&window.addEventListener("beforeunload",confirmUnload);var loadLanguage=function(lang,callback){$.getScript("js/language/"+lang+".js",function(data){Language.language=lang,eval(data),menuBar&&(edenUI.menu=new EdenUI.MenuBar),options&&options.noload||(edenUI.feedback=new EdenUI.Feedback,edenUI.explorer=new EdenUI.Explorer),callback()})},loadPlugins=function(a,b){var c=function(){if(a.length>0){var d=a.shift();edenUI.loadPlugin(d,c)}else b()};c()};doneLoading=function(a){window.scrollTo(0,0),edenUI.finishedLoading(),exec&&(";"!=exec.slice(-1)&&(exec+=";"),eden.execute2(exec)),""==myid&&""==master||(eden.peer=new Eden.Peer(""!=master?master:void 0,""!=myid?myid:void 0)),callback&&callback(a)},loadLanguage(lang,function(){options&&options.noload?Eden.DB.connect(Eden.DB.repositories[Eden.DB.repoindex],function(){console.log("DONE LOADING"),doneLoading(!0)}):loadPlugins(plugins,function(){$.getJSON("config.json",function(a){rt.config=a,Eden.DB.connect(Eden.DB.repositories[Eden.DB.repoindex],function(){""!=load?(null!==mode&&""!=mode&&eden.root.lookup("jseden_project_mode").assign(mode,eden.root.scope,Symbol.defaultAgent),Eden.Project.load(parseInt(load),null===vid||""==vid?void 0:parseInt(vid),null===readPassword||""==readPassword?void 0:readPassword,function(){doneLoading(!0)})):""!=restore?(null!==mode&&""!=mode&&eden.root.lookup("jseden_project_mode").assign(mode,eden.root.scope,Symbol.defaultAgent),Eden.project.restore(),doneLoading(!0)):doneLoading(!1)}),Eden.DB.repoindex=(Eden.DB.repoindex+1)%Eden.DB.repositories.length})})})})}function EdenSyntaxData(){this.value=void 0,this.error=!1,this.line=0}function EdenStream(a){this.code=a,this.position=0,this.position_stack=[0],this.prevposition=0,this.line=1,this.prevline=1,this.data=new EdenSyntaxData}function edenTokenTest(a){for(var b=new EdenStream(a),c=[],d={};b.valid();)c.push(b.readToken(d));return c}function sortByCount(a){var b=a.reduce(function(a,b){return a[b]=(a[b]||0)+1,a},{});return Object.keys(b).sort(function(a,c){return b[a]=b&&d.push(e);return d}function negativeFilter(a,b){for(var c=b.reduce(function(a,b){return a[b]=(a[b]||0)+1,a},{}),d=[],e=0;e0&&(e.insert[g+l].consecutive=!0),e.insert[g+l].partial=null===k,h+=lines[l].length,l0&&(e.remove[f+l].consecutive=!0),i+=lines[l].length,l0){for(var j=0;j0){for(var j=0;j=d+window.innerWidth||this.lastDialogLeft+this.lastDialogWidth=e+window.innerHeight||this.lastDialogTop+this.lastDialogHeightd+window.innerWidth?(d=this.lastDialogLeft+this.lastDialogWidth-window.innerWidth,f=!0):this.lastDialogLefte+window.innerHeight-edenUI.menuBarHeight?(e=this.lastDialogTop+this.lastDialogHeight-window.innerHeight-edenUI.menuBarHeight+edenUI.scrollBarSize2+edenUI.bottomBarHeight,f=!0):this.lastDialogTop=0;a--){var b=this.overrides[a];if(void 0!==b.end){if(b.isin){var c=isbound?b.start.value.length:b.start?b.start.length:0;return b.index=0;b--){var c=this.overrides[b];if(void 0!==c.end||c.isin){var d=c.start instanceof BoundValue,e=d?c.start.value.length:c.start?c.start.length:0;if(c.isin){if(c.index "+a)}},Symbol.prototype.logError=function(a){for(var b in this.loggers){var c=this.loggers[b];c.call(this,a)}},Symbol.prototype.getEdenCode=function(){return"&"+this.name},Symbol.prototype.trigger=function(){try{this.value().call(this,this.context,this.context.scope)}catch(a){var b=new Eden.RuntimeError((void 0),Eden.RuntimeError.PROCAGENT,(void 0),"Triggered proc failed: "+a);eden.emit("error",[this,b])}},Symbol.prototype.fireJSObservers=function(){for(var a in this.jsObservers)try{this.jsObservers[a](this,this.value())}catch(b){var c=new Eden.RuntimeError((void 0),Eden.RuntimeError.JSOBSERVER,(void 0),"JavaScript observer '"+a+"' failed: "+b);eden.emit("error",[this,c]);var d;if(this.context){var e=this.cache.value;d="object"==typeof e&&e.jsExceptions}else d=!1;throw b}},Symbol.prototype.expire=function(a,b,c,d){if(this.has_evaled||d){for(var e in this.observers)c[e]=this.observers[e];this.definition&&(this.cache.up_to_date=!1,this.has_evaled=!1,a[this.name]=b.value,b.value++,d&&(this.def_scope=void 0)),this.needsGlobalNotify=Symbol.EXPIRED;for(var f in this.subscribers){var g=this.subscribers[f];g&&g.expire(a,b,c,d)}}},Symbol.prototype.isDependentOn=function(a){if(a==this.name||this.dependencies[a])return!0;var b;for(var c in this.dependencies)if(b=this.dependencies[c],b.isDependentOn(a))return!0;for(var c in this.dynamicDependencies)if(b=this.dynamicDependencies[c],b.isDependentOn(a))return!0;return!1},Symbol.prototype.getDependencies=function(){var a=[];for(var b in this.dependencies)a.push(b);return console.log("Dependencies"),a},Symbol.prototype.assertNotDependentOn=function(a,b){if(void 0===b&&(b=[]),b.push(this.name),this.dependencies[a]){var c=b.join(" -> ")+" -> "+a+" -> "+b[0];throw new Error("Cyclic dependency detected: "+c)}var d;for(var e in this.dependencies)d=this.dependencies[e],d.assertNotDependentOn(a,b);for(var e in this.dynamicDependencies)d=this.dynamicDependencies[e],d.assertNotDependentOn(a,b);b.pop()},Symbol.prototype.addSubscriber=function(a,b){this.garbage=!1,this.assertNotDependentOn(a),this.subscribers[a]=b},Symbol.prototype.removeSubscriber=function(a){delete this.subscribers[a],void 0===this.origin&&this.canSafelyBeForgotten()&&this.forget()},Symbol.prototype.canSafelyBeForgotten=function(){for(var a in this.subscribers)return!1;for(var b in this.observers)return!1;return!0},Symbol.prototype.forget=function(){this.origin=void 0,this.clearEvalIDs(),this.evalResolved=!0,this.definition=void 0,this.cache.value=void 0,this.cache.up_to_date=!0,this.context&&this.context.expireSymbol(this),this.clearObservees(),this.clearDependencies(),this.garbage=!0;for(var a in this.jsObservers)this.jsObservers[a].call(this,this,void 0);this.jsObservers={},this.context.queueForGarbageCollection(this)},Symbol.prototype.addObserver=function(a,b){this.garbage=!1,this.observers[a]=b},Symbol.prototype.addJSObserver=function(a,b){if("function"!=typeof b)throw new Error("Failed adding JavaScript observer "+b);this.jsObservers[a]=b,0==this.cache.up_to_date&&this.value()},Symbol.prototype.removeObserver=function(a){delete this.observers[a],void 0===this.origin&&this.canSafelyBeForgotten()&&this.forget()},Symbol.prototype.removeJSObserver=function(a){delete this.jsObservers[a]},Symbol.prototype.addExtension=function(a,b,c,d,e){if(!this.definition)throw new Error(Eden.RuntimeError.EXTENDSTATIC);void 0===this.extend&&(this.extend={}),this.extend[a]={code:b,source:c,deps:e},this.subscribe(e),this.needsGlobalNotify=Symbol.REDEFINED,this.context&&this.context.expireSymbol(this)},Symbol.prototype.listAssign=function(a,b,c,d,e){if(this.definition)throw new Error(Eden.RuntimeError.ASSIGNTODEFINED);for(var f=this.value(b),g=0;g0){this.needsGlobalNotify=f;var h=this;setTimeout(function(){h.processGlobalNotifyQueue()},0)}}else{var i=this.needsGlobalNotify;i.push.apply(i,f),i.push.apply(i,d)}}},Folder.prototype.processGlobalNotifyQueue=function(){for(var a=this.needsGlobalNotify,b=0;b4)return eden.error(new Error("forgetAll: This function requires at most 4 arguments."),"error"),[[],void 0,[]];if(0==arguments.length)a="";else if("string"==typeof arguments[0])a=arguments[0];else{if(!Array.isArray(arguments[0]))return void 0===arguments[0]?[[],void 0,[]]:(eden.error(new Error("forgetAll: The first argument must be a string, not a "+typeof arguments[0]),"error"),[[],void 0,[]]);g=arguments[0]}if(arguments.length>1){if("boolean"!=typeof arguments[1])return eden.error(new Error("forgetAll: The second argument must be a boolean, not a "+typeof arguments[1]),"error"),[[],void 0,[]];b=arguments[1]}else b=!0;if(void 0!==g&&arguments.length>2)return eden.error(new Error("forgetAll: Cannot specify case sensitivity when selecting using a list."),"error"),[[],void 0,[]];if(arguments.length>=3){if("boolean"!=typeof arguments[2])return eden.error(new Error("forgetAll: The third argument must be a boolean, not a "+typeof arguments[2]),"error"),[[],void 0,[]];c=arguments[2]}else c=void 0===g||2!=arguments.length||arguments[1];if(arguments.length>3){if("boolean"!=typeof arguments[3])return eden.error(new Error("forgetAll: The forth argument must be a boolean, not a "+typeof arguments[3]),"error"),[[],void 0,[]];d=arguments[3]}else d=!1;var h,i={},j=[],k={};if(void 0!==g)for(var l=0;l0&&c)if(x.length<=50)v=confirm("You are about to delete the following "+x.length+" symbols. Is this correct?\n\n"+x.join("\n"));else{var y=x.length-50;v=confirm("You are about to delete "+x.length+" symbols. Is this correct?\n\n"+x.slice(0,50).join("\n")+"\n...\n("+y+" more)")}else v=!0;if(v){root.beginAutocalcOff();for(m in k);for(var l=0;l"),this.$uimsg.appendTo("body"),this.$uimsg.hide(),this.messagetimeout=void 0,this.messagedisplaytime=5e3,this.eden.listenTo("executeFileLoad",this,function(a){edenUI.updateStatus("Loading "+a)}),this.eden.listenTo("executeError",this,function(a,b){console.error("DEPRECATED ERROR REPORTING",a);var c,e=d.htmlEscape(a.message);'
## ERROR number '+b.errorNumber+":
"+(b.path?"## "+b.path+"
":"")+e+"
\n\n";c="string"==typeof a?a:a.message,edenUI.showMessage("error","Error: "+c)}),this.listeners={},this.windowHighlighter=new WindowHighlighter(this),this.currentView=void 0,this.viewCategories={},this.numberOfViewCategories=0,this.addViewCategory("comprehension","Comprehension"),this.addViewCategory("interpretation","Making Definitions"),this.addViewCategory("history","History & State"),this.addViewCategory("visualization","Visualization"),this.addViewCategory("extension","Extensions"),this.addViewCategory("environment","Management"),$(document).on("click",function(a){if(a.ctrlKey||a.metaKey)for(var b=[],c=a.target;"BODY"!=c.nodeName;){var d=c.getAttribute("data-observables");d&&""!=d&&b.push.apply(b,d.split(",")),c=c.parentNode}})}function d(a){this.root=a,a.base=this,this.dictionary={},this.errorNumber=0,this.listeners={},this.reportErrors=!0}"undefined"!=typeof require&&"undefined"!=typeof exports&&(Polyglot=require("./polyglot").Polyglot,rt=require("./runtime").rt),c.prototype.brieflyHighlightView=function(a){var b=$("#"+viewName+"-dialog").dialog.parent();b.addClass("window-activated"),setTimeout(function(){b.removeClass("window-activated")},600)},c.prototype.cycleNextView=function(){this.stopHighlightingView(this.currentView,!0,!1);var a=Object.keys(this.activeDialogs);if(void 0===this.currentView)this.currentView=a[0];else for(i=0;i"+b+""):"error"==a&&this.$uimsg.html("
"+b+"
"),this.$uimsg.show("fast"),clearTimeout(this.messagetimeout),this.messagetimeout=setTimeout(this.hideMessage,this.messagedisplaytime)},c.prototype.finishedLoading=function(){this.loaded=!0},c.prototype.listenTo=listenTo,c.prototype.emit=emit,c.showTooltip=function(a,b){var c=document.getElementById("tooltip"),d=a.clientX+2,e=a.clientY+20,f=window.pageXOffset+window.innerWidth-d-15;f<200&&(d-=200-f,f=200),c.style.left=d+"px",c.style.maxWidth=f+"px",c.style.top=e+"px",c.innerHTML=b,c.style.display="block"},c.closeTooltip=function(){document.getElementById("tooltip").style.display="none"},c.prototype.options={},c.prototype.getOptionValue=function(a){if(a in this.options)return this.options[a];try{if(window.localStorage)return window.localStorage.getItem(a)}catch(b){return null}},c.prototype.setOptionValue=function(a,b){this.options[a]=String(b),this.emit("optionChange",[a,String(b)]);try{if(window.localStorage)return window.localStorage.setItem(a,b),!0}catch(c){return!1}},c.prototype.setDefaultOptionValue=function(a,b){null===this.getOptionValue(a)&&(this.options[a]=String(b),this.emit("optionChange",[a,String(b)]))},c.prototype.unsetOptionValue=function(a){delete this.options[a],this.emit("optionChange",[a,null]);try{window.localStorage&&window.localStorage.removeItem(a)}catch(b){}},c.prototype.fullscreen=function(a,b){var c=eden.root.lookup(b),d=c.value();if(document.webkitExitFullscreen)if(d){document.onwebkitfullscreenchange=function(){document.webkitIsFullScreen||(c.assign(!1,eden.root.scope,Symbol.hciAgent),edenUI.menu.show())};var e=document.getElementById(a+"-canvascontent");e.webkitRequestFullscreen(),edenUI.menu.hide()}else document.webkitExitFullscreen(),edenUI.menu.show();else if(document.mozCancelFullScreen)if(d){document.onmozfullscreenchange=function(){document.mozFullScreen||(c.assign(!1,eden.root.scope,Symbol.hciAgent),edenUI.menu.show())};var e=document.getElementById(a+"-canvascontent");e.mozRequestFullScreen(),edenUI.menu.hide()}else document.mozCancelFullScreen(),edenUI.menu.show()},c.prototype.regExpFromStr=function(a,b,c,d){var e,f,g,h=!0,i=3;"object"==typeof a&&(g=a,a=g[0].value),void 0===b&&(b="");var j;if(void 0===d)j=!/[\\+^$|({[]|(\.\*[^\s*?])/.test(a)&&"false"!==this.getOptionValue("optSimpleWildcards");else if("simple"==d)j=!0;else{if("regexp"!=d)throw new Error("EdenUI.regExpFromStr: Unsupported search language "+d);j=!1}if(/[A-Z]/.test(a)||(b+="i"),j){a=a.replace(/([\\+^$.|(){[])/g,"\\$1").replace(/([*?])/g,".$1");for(var k=a.split(new RegExp("\\s+(?:"+Language.ui.search.disjunction+"|or)\\s+","i")),l=0;l=0?"<>";else{b.push(a),f="[";for(var g=0;g0&&(f+=d.edenCodeForValue(a[a.length-1],b,c)),f+="]",b.pop()}else if("object"==e){if("getEdenCode"in a?f=a.getEdenCode(c):"keys"in a&&Array.isArray(a.keys)&&a.keys.length>0&&"parent"in a&&a.parent instanceof Symbol?f="&"+a.parent.name.slice(1)+"["+a.keys[0]+"]":"object"==typeof window&&"object"==typeof document&&"function"==typeof Element&&(a==window?f="${{ window }}$":a==document?f="${{ document }}$":a==document.documentElement?f="${{ document.documentElement }}$":a==document.body?f="${{ document.body }}$":a instanceof Element&&a.id&&(f='${{ document.getElementById("'+a.id+'") }}$')),""==f)if(void 0===b&&(b=[]),b.indexOf(a)!=-1)f+="<>";else{b.push(a),f="Object(";for(var h in a)h in Object.prototype||(f=f+h+", "+d.edenCodeForValue(a[h],b,c)+", ");"Object("!=f&&(f=f.slice(0,-2)),f+=")",b.pop()}}else f="function"==e?"${{\n\t"+a.toString().replace(/\n/g,"\n\t")+"\n}}$":"number"==e&&c?a.toFixed(c):String(a);return f},d.edenCodeForValues=function(){for(var a="",b=0;bc+1&&(i=i.slice(0,c)+"...",j=!0);else if(Array.isArray(b))if(void 0===g&&(g=[]),g.indexOf(b)!=-1)i+="...";else{g.push(b),i="[";for(var k=0;k=c-1){"..."!=i.slice(-3)&&(i+="..."),j=!0;break}i+=" "}b.length>0&&!j&&(i=d.prettyPrintValue(i,b[b.length-1],c,e,f,g)),i+="]",g.pop()}else if("object"==h){if(b instanceof Symbol?i=b.getEdenCode():"keys"in b&&Array.isArray(b.keys)&&b.keys.length>0&&"parent"in b&&b.parent instanceof Symbol?i="&"+b.parent.name.slice(1)+"["+b.keys[0]+"]":"object"==typeof window&&"object"==typeof document&&"function"==typeof Element&&(b==window?i="${{ window }}$":b==document?i="${{ document }}$":b==document.documentElement?i="${{ document.documentElement }}$":b==document.body?i="${{ document.body }}$":b instanceof Element&&b.id&&(i='${{ document.getElementById("'+b.id+'") }}$')),""==i)if(b.toString!=Object.prototype.toString)i=b.toString(),void 0!==c&&i.length>c&&(i=i.slice(0,c)+"...",j=!0);else if(void 0===g&&(g=[]),g.indexOf(b)!=-1)i+="...";else{g.push(b),i="{";var l=!1;for(var m in b)if(!(m in Object.prototype)){if(l){i=i.slice(0,-1)+"...",j=!0;break}if(i=i+m+": ",i=d.prettyPrintValue(i,b[m],c,e,f,g),"..."==i.slice(-3)){j=!0;break}void 0!==c&&i.length>=c&&(l=!0),i+=", "}"{"==i||j||(i=i.slice(0,-2)),i+="}",g.pop()}}else"function"==h?e?(i="${{\n\t"+b.toString().replace(/\n/g,"\n\t")+"\n}}$",void 0!==c&&i.length>c&&(i=i.slice(0,c)+"...",j=!0)):i="func":i=String(b);if(a)return a+i;var n=d.htmlEscape(i,!f);return n=n.replace(/\.\.\./g,"…"),f||(n=n.replace(/\n/g,"\\n")),n},d.htmlEscape=function(a,b,c){return void 0===a?"":(a=String(a),a=a.replace(/&/g,"&"),a=a.replace(//g,">"),a=a.replace(/"/g,"""),a=a.replace(/'/g,"'"),c?a=b?a.replace(/\n/g," "):a.replace(/\n/g,"
"):b||(a=a.replace(/\n/g,"
\n")),a)},d.prototype.nextEvalID=0,d.prototype.initialDefinition=function(){console.error("INIT DEF DEP")},d.prototype.getDefinition=function(a,b){return b.eden_definition?b.eden_definition+";":a+" = "+b.context.scope.lookup(b.name).value+";"},a.EdenUI=c,a.Eden=d,"undefined"!=typeof require&&"undefined"!=typeof exports&&(exports.Eden=d)}("undefined"!=typeof window?window:global),Eden.DB={directory:{},meta:{},remoteMeta:{},remoteURL:void 0,username:void 0,userid:void 0,repositories:["http://jseden.dcs.warwick.ac.uk/construalmanager","http://localhost:18882"],repoindex:0,retrycount:0,connected:!1,searchServer:"http://jseden.dcs.warwick.ac.uk"},Eden.DB.listeners={},Eden.DB.emit=emit,Eden.DB.listenTo=listenTo,Eden.DB.isConnecting=function(){return void 0!==Eden.DB.remoteURL},Eden.DB.isConnected=function(){return Eden.DB.connected},Eden.DB.isLoggedIn=function(){return void 0!==Eden.DB.username},Eden.DB.logOut=function(a){Eden.DB.isLoggedIn()&&$.ajax({url:Eden.DB.remoteURL+"/logout",type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(b){function c(){Eden.DB.isConnected()&&void 0===Eden.DB.username&&setTimeout(function(){Eden.DB.getLoginName(function(a){a?(Eden.DB.emit("login",[a]),eden.root.lookup("jseden_pm_user").assign(a,eden.root.scope,Symbol.localJSAgent)):c()})},5e3)}Eden.DB.username=void 0,a&&a(),c()},error:function(a){Eden.DB.disconnect(!0)}})},Eden.DB.connect=function(a,b){function c(a){for(var b in a)a[b].missing=!0,a[b].children&&c(a[b].children)}function d(){Eden.DB.isConnected()&&setTimeout(function(){Eden.DB.getLoginName(function(a){a?d():Eden.DB.disconnect()})},3e5)}function e(){Eden.DB.isConnected()&&void 0===Eden.DB.username&&setTimeout(function(){Eden.DB.getLoginName(function(a){a?(Eden.DB.emit("login",[a]),eden.root.lookup("jseden_pm_user").assign(a,eden.root.scope,Symbol.localJSAgent),d()):e()})},5e3)}Eden.DB.remoteURL=a,c(Eden.DB.directory),Eden.DB.refreshint=setInterval(function(){for(var a in Eden.DB.directory)Eden.DB.directory[a].missing=!0},2e4),Eden.DB.getLoginName(function(c){Eden.DB.isConnected()?(Eden.DB.retrycount=0,b&&b(Eden.DB.isConnected()),Eden.DB.emit("connected",[a]),eden.root.lookup("jseden_pm_connected").assign(!0,eden.root.scope,Symbol.localJSAgent),c?(Eden.DB.emit("login",[c]),eden.root.lookup("jseden_pm_user").assign(c,eden.root.scope,Symbol.localJSAgent)):e()):b&&b(Eden.DB.isConnected())})},Eden.DB.disconnect=function(a){Eden.DB.remoteURL=void 0,Eden.DB.connected&&(Eden.DB.emit("disconnected",[]),eden.root.lookup("jseden_pm_connected").assign(!1,eden.root.scope,Symbol.localJSAgent)),Eden.DB.connected=!1,Eden.DB.refreshint&&(clearInterval(Eden.DB.refreshint),Eden.DB.refreshint=void 0),a&&(Eden.DB.retrycount<12&&Eden.DB.retrycount++,setTimeout(function(){Eden.DB.repoindex>=Eden.DB.repositories.length&&(Eden.DB.repoindex=Eden.DB.repositories.length-1),Eden.DB.connect(Eden.DB.repositories[Eden.DB.repoindex]),Eden.DB.repoindex=(Eden.DB.repoindex+1)%Eden.DB.repositories.length},200*Math.pow(2,Math.ceil(Eden.DB.retrycount/Eden.DB.repositories.length))))},Eden.DB.getLoginName=function(a){Eden.DB.isConnecting()?$.ajax({url:Eden.DB.remoteURL+"/user/details",type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(b){Eden.DB.connected=!0,null==b||b.error?(Eden.DB.username=void 0,a()):(Eden.DB.username=b.name,Eden.DB.userid=b.id,!b.id||""!=b.name&&b.name||(Eden.DB.username="NoName"),a(Eden.DB.username))},error:function(b,c,d){Eden.DB.disconnect(!0),a(void 0)}}):a()},Eden.DB.save=function(a,b,c){Eden.DB.isConnected()?$.ajax({url:this.remoteURL+"/project/add",type:"post",crossDomain:!0,xhrFields:{withCredentials:!0},data:{projectID:a.id,title:a.title,source:a.generate(),tags:a.tags.join(" "),minimisedTitle:a.name,from:a.vid,image:a.thumb,listed:b,metadata:JSON.stringify({description:a.desc}),parentProject:a.parentid},success:function(b){null===b||b.error?(console.error(b),Eden.DB.emit("error",[b?b.description:"No response from server"]),c&&c(!1)):(console.log("Saved",b),a.id=b.projectID,a.vid=b.saveID,a.readPassword=b.readPassword,c&&c(!0))},error:function(a,b,d){Eden.DB.handleError(a,b,d),c&&c(!1)}}):(console.error("Cannot upload, not connected to server"),c&&c(!1),eden.error("Cannot upload "+path+", not connected to server"))},Eden.DB.getVersions=function(a,b){Eden.DB.isConnected()?$.ajax({url:Eden.DB.remoteURL+"/project/versions?projectID="+a,type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(a){b(a)},error:function(a){Eden.DB.disconnect(!0)}}):b(void 0)},Eden.DB.load=function(a,b,c,d){3==arguments.length&&(d=c,c=void 0),Eden.DB.isConnected()?$.ajax({url:Eden.DB.remoteURL+"/project/get?projectID="+a+(b?"&to="+b:"")+(c?"&readPassword="+c:""),type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(c){null==c||c.error?(d(void 0,"No such version"),console.error("No such version "+b+" for "+a),console.log(c),Eden.DB.emit("error",[c?c.description:"No response from server"])):d(c)},error:function(a,b,c){Eden.DB.handleError(a,b,c),d(void 0,"Disconnected")}}):d&&d(void 0,"Disconnected")},Eden.DB.search=function(a,b,c,d,e){var f=this.remoteURL+"/project/";f+=""==a?"search?limit="+c+"&offset="+(b-1)*c:"search?limit="+c+"&offset="+(b-1)*c+"&query="+encodeURIComponent(a),d&&(f+="&by="+d),$.ajax({url:f,type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(a){return a&&a.error?(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]),void e(void 0)):a?void e(a):void e(void 0)},error:function(a,b,c){Eden.DB.handleError(a,b,c),e(void 0)}})},Eden.DB.getMeta=function(a,b){var c=this.remoteURL+"/project/";c+="search?limit=20&query=.id("+a+")",$.ajax({url:c,type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(a){return a&&a.error?(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]),void b(void 0)):a?void b(a):void b(void 0)},error:function(a,b,c){Eden.DB.handleError(a,b,c)}})},Eden.DB.remove=function(a,b){$.ajax({url:this.remoteURL+"/project/remove",type:"post",crossDomain:!0,xhrFields:{withCredentials:!0},data:{projectID:a},success:function(a){null===a||a.error?(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]),b&&b(!1)):(console.log("Removed",a),b&&b(!0))},error:function(a,c,d){Eden.DB.handleError(a,c,d),b&&b(!1)}})},Eden.DB.rate=function(a,b){$.ajax({url:this.remoteURL+"/project/rate",type:"post",crossDomain:!0,xhrFields:{withCredentials:!0},data:{projectID:a,stars:b},success:function(a){(null===a||a.error)&&(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]))},error:function(a,b,c){Eden.DB.handleError(a,b,c)}})},Eden.DB.searchSelector=function(a,b,c){$.ajax({url:this.remoteURL+"/code/search?selector="+a.replace("#","%23")+"&outtype="+b,type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(a){return(null===a||a.error)&&(Eden.DB.emit("error",[a?a.description:"No response from server"]),c([])),a?void c(a):void c([])},error:function(a,b,d){c([]),Eden.DB.handleError(a,b,d)}})},Eden.DB.postComment=function(a,b,c){var d=a?a.id:-1,e=a?a.vid:-1;Eden.DB.isLoggedIn()&&$.ajax({url:this.remoteURL+"/comment/post",type:"post",crossDomain:!0,xhrFields:{withCredentials:!0},data:{projectID:d,versionID:e,publiclyVisible:c?0:1,comment:b},success:function(a){(null===a||a.error)&&(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]))},error:function(a,b,c){Eden.DB.handleError(a,b,c)}})},Eden.DB.searchComments=function(a,b,c,d,e,f){var g=a?a.id:-1;Eden.DB.isConnected()&&$.ajax({url:this.remoteURL+"/comment/search?projectID="+g+(e?"&newerThan="+e:"")+"&offset="+(c-1)*d+"&limit="+d,type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(a){return a?void f(a):void f([])},error:function(a,b,c){f([]),Eden.DB.handleError(a,b,c)}})},Eden.DB.removeComment=function(a){Eden.DB.isLoggedIn()&&$.ajax({url:this.remoteURL+"/comment/delete",type:"post",crossDomain:!0,xhrFields:{withCredentials:!0},data:{commentID:a},success:function(a){(null===a||a.error)&&(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]))},error:function(a,b,c){Eden.DB.handleError(a,b,c)}})},Eden.DB.follow=function(a,b){Eden.DB.isLoggedIn()&&$.ajax({url:this.remoteURL+"/social/followproject?projectID="+a, type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(a){null===a||a.error?(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]),b&&b(!1)):b&&b(!0)},error:function(a,c,d){Eden.DB.handleError(a,c,d),b&&b(!1)}})},Eden.DB.adminCommentActivity=function(a,b,c){Eden.DB.isLoggedIn()&&$.ajax({url:this.remoteURL+"/comment/activity?limit=10&offset="+b+(a?"&newerThan="+a:""),type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(a){null===a||a.error?(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]),c&&c(!1)):c&&c(a)},error:function(a,b,d){Eden.DB.handleError(a,b,d),c&&c(!1)}})},Eden.DB.handleError=function(a,b,c){console.log("DB ERROR",b,c),"error"!=b||c?"error"==b?Eden.DB.emit("error",[c]):"timeout"==b?(Eden.DB.emit("error",["Network timeout"]),Eden.disconnect(!0)):(Eden.DB.emit("error","Unknown network error"),Eden.disconnect(!0)):(Eden.DB.disconnect(!0),Eden.DB.emit("error",["Not connected to construal cloud"]))},Eden.DB.adminProjectActivity=function(a,b,c){Eden.DB.isLoggedIn()&&$.ajax({url:this.remoteURL+"/project/activity?limit=15&offset="+b+(a?"&newerThan="+a:""),type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(a){null===a||a.error?(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]),c&&c(!1)):c&&c(a)},error:function(a,b,d){Eden.DB.handleError(a,b,d),c&&c(!1)}})},Eden.DB.getPopularTags=function(a,b){$.ajax({url:this.remoteURL+"/project/tags?tag="+a,type:"get",crossDomain:!0,xhrFields:{withCredentials:!0},success:function(a){null===a||a.error?(console.error(a),Eden.DB.emit("error",[a?a.description:"No response from server"]),b&&b(!1)):b&&b(a)},error:function(a,c,d){Eden.DB.handleError(a,c,d),b&&b(!1)}})},function(){function a(a,b){return root.lookup("view_"+a+"_"+b)}function b(a){return $("#"+a+"-dialog")}EdenUI.prototype.menuBarHeight=45,EdenUI.prototype.dialogBorderWidth=1,EdenUI.prototype.titleBarHeight=0,EdenUI.prototype.largeTitleBar=41.22+EdenUI.prototype.dialogBorderWidth,EdenUI.prototype.scrollBarSize=14+EdenUI.prototype.dialogBorderWidth,EdenUI.prototype.scrollBarSize2=window.innerHeight-$(window).height(),EdenUI.prototype.dialogFrameWidth=2*EdenUI.prototype.dialogBorderWidth,EdenUI.prototype.dialogFrameHeight=EdenUI.prototype.titleBarHeight+EdenUI.prototype.dialogBorderWidth,EdenUI.prototype.bottomBarHeight=34.906,EdenUI.prototype.gridSizeX=Math.floor(30*window.innerWidth/1920),EdenUI.prototype.gridSizeY=Math.floor(30*window.innerHeight/1920),EdenUI.prototype.minimumWindowWidthShowing=72+EdenUI.prototype.dialogBorderWidth,EdenUI.prototype.createEmbedded=function(a,b){if(this.embeddedInstances[a])return this.embeddedInstances[a];var c;return edenUI.views[b].embed?c=edenUI.views[b].embed(a,a,""):edenUI.views[b].embedded&&(c=edenUI.views[b].embedded(a,a,"")),c?(this.embeddedInstances[a]=c,c):void 0},EdenUI.prototype.createView=function(c,d,e){function f(a){return"view_"+c+"_"+a}function g(a,b){n.resizeView(c)}function h(a,b){n.moveView(c)}function i(a,b){var d=z.dialogExtend("state");"hidden"==b?"minimized"!=d&&n.minimizeView(c):"maximized"==b||z.dialog("isOpen")&&"minimized"!=d&&"collapsed"!=d||n.showView(c)}function j(a,b){var c=b;void 0!==w.titleBarInfo&&(c=c+" ("+w.titleBarInfo+")"),z.dialog("option","title",c),edenUI.menu.updateViewsMenu()}function k(a,b){lockVal=b,b?(z.siblings(".ui-dialog-titlebar").css("display","none"),z.dialog("option","resizable",!1),n.resizeView(c)):(z.siblings(".ui-dialog-titlebar").css("display","block"),z.dialog("option","resizable",!0),n.resizeView(c))}function l(a,b){var c=z.get(0).parentNode.style;b?(c.border="none",c.boxShadow="none"):(c.border="1px solid #777",c.boxShadow="0 0 15px #4a6887")}function m(a,b){b?n.pinView(c):n.unpinView(c)}if(!(d in this.views))return void this.eden.error(new Error("View type "+d+" is unavailable. Check that the associated plug-in is loaded."));"name"in this.views[d]&&(c=this.views[d].name);var n=this,o=Symbol.defaultAgent,p=this.activeDialogs[c],q=a(c,"visibility"),r=q.value(),s=a(c,"title"),t=s.value();if(p==d)return"visible"!=r&&q.assign("visible",root.scope,o),this.brieflyHighlightView(c),this.viewInstances[c];this.eden.root.beginAutocalcOff(),void 0!==p&&(t==this.views[p].title&&(t=void 0),this.destroyView(c,!1)),this.titleBarHeight="ScriptView"==p?this.largeTitleBar:this.titleBarHeight;var u=this.menuBarHeight,v=this.views[d].title,w=this.views[d].dialog(c+"-dialog",v);void 0===w&&(w={}),this.viewInstances[c]=w;var x,y=(w.position,edenUI.getOptionValue("optCollapseToTitleBar"));x="true"==y?"collapse":"maximize";var z=b(c);z.dialog({closeOnEscape:!1,position:{using:function(){}},beforeClose:function(){return w.closing?(w.closing=!1,!0):n.closeView(c)},focus:function(){}});var A=[f("type"),f("x"),f("y"),f("width"),f("height"),f("lock"),f("noborder"),f("title"),f("visibility")];z.get(0).setAttribute("data-observables",A.join(","));var B=this.getDialogWindow(c);z.dialogExtend({dblclick:x,minimizable:!0,maximizable:!0,beforeMinimize:function(a){return $(a.target).parent().removeClass("window-activated"),n.hideView(c),!1},minimize:function(){var a=b(c).data("dialog-extend-minimize-controls");a.css("position","relative"),a.css("top",""),a.css("left","")},maximize:function(a){var b=B[0],c=z[0];b.style.top=u+"px";var d=window.innerHeight-u-n.scrollBarSize2-2*n.dialogBorderWidth;"true"!=edenUI.getOptionValue("optHideOnMinimize")&&(d-=n.bottomBarHeight),b.style.height=d+"px",c.style.height=d-n.titleBarHeight+"px"},restore:function(a){z.dialog("moveToTop"),n.brieflyHighlightView(a.target.id.slice(0,-7)),z.dialog("widget").draggable("option","containment",[-Number.MAX_VALUE,u,Number.MAX_VALUE,Number.MAX_VALUE])}}),this.activeDialogs[c]=d;var C=a(c,"type");C.value()!=d&&(C.removeJSObserver("changeType"),C.assign(d,root.scope,Symbol.localJSAgent),C.addJSObserver("changeType",function(a,b){void 0!==b&&root.lookup("views_list").value().indexOf(c)!==-1&&n.createView(c,b)}));var D=root.lookup("views_list"),E=D.value();Array.isArray(E)?E.indexOf(c)===-1&&(E=E.slice(),E.push(c),D.assign(E,root.scope,Symbol.localJSAgent)):D.assign([c],root.scope,Symbol.localJSAgent);var F=a(c,"lock"),G=F.value();widthSym=a(c,"width"),widthSym.addJSObserver("plugins",g),widthSym.definition||void 0!==widthSym.value()||widthSym.assign(z.dialog("option","width"),root.scope,o);var H=a(c,"height");H.addJSObserver("plugins",g),H.definition||void 0!==H.value()||H.assign(z.dialog("option","height")-(G?0:this.titleBarHeight),root.scope,o),g();var I=z.closest(".ui-dialog").position(),J=a(c,"x");J.addJSObserver("plugins",h),J.definition||void 0!==J.value()||J.assign(I.left,root.scope,o);var K=a(c,"y");K.addJSObserver("plugins",h),K.definition||void 0!==K.value()||K.assign(I.top,root.scope,o),h(),"visible"!=r&&(void 0===r?q.assign("visible",root.scope,o):i(q,r)),q.addJSObserver("changeState",i);var L=w.titleBarInfo;delete w.titleBarInfo,Object.defineProperty(w,"titleBarInfo",{get:function(){return L},set:function(a){L=a;var b=s.value();void 0!==a&&(b=b+" ("+a+")"),z.dialog("option","title",b)},enumerable:!0}),s.addJSObserver("updateTitleBar",j),void 0===t?s.assign(v,root.scope,o):j(s,t),F.addJSObserver("changeState",k),void 0!==G&&k(F,G);var M=a(c,"noborder");M.addJSObserver("changeState",l);var N=M.value();void 0!==N&&l(M,N);var O=a(c,"pin");O.addJSObserver("changeState",m);var P=O.value();void 0!==P?m(O,P):this.unpinView(c),z.dialog("widget").draggable("option","containment",[-Number.MAX_VALUE,u,Number.MAX_VALUE,Number.MAX_VALUE]),z.resizeExtend=0,z.on("dialogresizestop",function(b,d){z.previousWidth=void 0,z.momentum=0,z.resizeExtend=0;var e=a(c,"width"),f=a(c,"height"),g=n.eden.root;g.beginAutocalcOff(),e.assign(d.size.width,g.scope,Symbol.hciAgent),f.assign(d.size.height-n.titleBarHeight,g.scope,Symbol.hciAgent),g.endAutocalcOff()}),z.on("dialogdragstop",function(b,d){var e=n.eden.root;e.beginAutocalcOff(),console.log(d),a(c,"x").assign(d.position.left,eden.root.scope,Symbol.hciAgent),a(c,"y").assign(d.position.top,eden.root.scope,Symbol.hciAgent),e.endAutocalcOff()}),z.on("dialogdragstart",function(){if(a(c,"x").definition||a(c,"y").definition)return!1}),z.on("dialogresizestart",function(){if(a(c,"width").definition||a(c,"height").definition)return!1}),this.eden.root.endAutocalcOff(),this.emit("createView",[c,d]);var Q=a(c,"nostack");return Q.value()?z.get(0).parentNode.className+=" ui-back":z.get(0).parentNode.className+=" ui-front",w},EdenUI.prototype.closeView=function(a){return this.hideView(a),edenUI.eden.root.collectGarbage(),!0},EdenUI.prototype.destroyAllViews=function(){for(var a in this.viewInstances)this.destroyView(a,!0)},EdenUI.prototype.destroyView=function(a,c){if(a in this.viewInstances&&!this.viewInstances[a].closing){this.viewInstances[a].closing=!0,this.viewInstances[a].destroy&&this.viewInstances[a].destroy(),root.forgetAll("^View_"+a+"_",!0,!1,!0),c?root.forgetAll("^view_"+a+"_",!0,!1,!0):root.lookup("view_"+a+"_title").removeJSObserver("updateTitleBar");var d=b(a);if(d.dialog("destroy"),d.remove(),d.html(""),delete this.activeDialogs[a],delete this.viewInstances[a],c){var e=root.lookup("views_list"),f=e.value();if(Array.isArray(f)){var g=f.indexOf(a);if(g!==-1){var h;0==g?h=f.slice(1):(f.splice(g,1),h=f),e.assign(h,root.scope,Symbol.hciAgent)}}}this.emit("destroyView",[a])}},EdenUI.prototype.getDialogContent=function(a){return b(a)},EdenUI.prototype.getDialogWindow=function(a){return b(a).parent()},EdenUI.prototype.showView=function(a){var c=b(a);c.dialog("open").dialog("moveToTop");var d=c.dialogExtend("state");return"normal"!=d&&"maximized"!=d&&c.dialogExtend("restore"),this.activeDialogs[a]},EdenUI.prototype.updateView=function(a,b){var c=this.viewInstances[a];c&&c.update&&c.update(b)},EdenUI.prototype.highlightView=function(a,b){if(b)this.windowHighlighter.highlight(a);else{var c=this.getDialogContent(a).data("dialog-extend-minimize-controls")||this.getDialogWindow(a);c.addClass("window-highlighted")}},EdenUI.prototype.stopHighlightingView=function(a,b,c){if(b)this.windowHighlighter.stopHighlight(a,c),c&&this.getDialogContent(a).dialog("moveToTop");else{var d=this.getDialogContent(a).data("dialog-extend-minimize-controls")||this.getDialogWindow(a);d.removeClass("window-highlighted")}},EdenUI.prototype.brieflyHighlightView=function(a){var b=this.getDialogWindow(a);b.addClass("window-activated"),setTimeout(function(){b.removeClass("window-activated")},600)},EdenUI.prototype.hideView=function(a){a in this.viewInstances&&(this.viewInstances[a].closing=!0,b(a).dialog("close"))},EdenUI.prototype.minimizeView=function(a){var c=edenUI.getOptionValue("optHideOnMinimize");if("true"==c)this.hideView(a);else{if(!(a in this.viewInstances))return;b(a).dialogExtend("minimize")}},EdenUI.prototype.minimizeObscuredViews=function(a){if("true"!=edenUI.getOptionValue("optHideOnMinimize")){var c=b(a),d=c.closest(".ui-dialog");if(!d.is(this.windowHighlighter.lastDialog)&&"normal"==c.dialogExtend("state"))for(var e=c.get(0),f=0,g=d.position(),h=g.left,i=g.top,j=c.dialog("option","width")+2*EdenUI.prototype.dialogBorderWidth,k=c.dialog("option","height")+2*EdenUI.prototype.dialogBorderWidth,l=d.hasClass("ui-top"),m=$(".ui-dialog-content"),n=0;n=h-f&&r+t<=h+j+f&&s>=i-f&&s+u<=i+k+f&&o.dialogExtend("minimize")}}}}},EdenUI.prototype.moveView=function(c){var d,e,f=b(c),g=a(c,"x"),h=a(c,"y"),i=g.value(),j=h.value(),k=this.minimumWindowWidthShowing-f.dialog("option","width");d=i'),g=function(a){return function(b){f.dialog("destroy"),f.remove(),e(a)}},h=$("
"+b+"
");f.append(h);for(var i=[],j=0;j1&&d[f[0]].push(decodeURIComponent(f[1]))}return d},URLUtil.getArrayParameterByName=function(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");for(var b="[\\?&]"+a+"=([^&#]*)",c=new RegExp(b,"g"),d=window.location.href,e=c.exec(d),f=[];null!==e;){var g=decodeURIComponent(e[1].replace(/\+/g," "));f.push(g),e=c.exec(d)}return f},URLUtil.isCrossDomain=function(a){var b=a.match(/^([a-zA-Z][a-zA-Z\d+.\-]*:)(\/\/)?([^\/@]*@)?([^\/:]+)(:\d+)?(\/|$)/);return null!==b&&(b[1]!=window.location.protocol||b[4]!=document.domain||b[5].slice(1)!=window.location.port)},URLUtil.downloadFile=function(a){var b=a.url,c=a.dataType,d=a.sync,e=a.success,f=a.error;if(void 0===c&&(c="text"),"function"!=typeof f)throw new Error("An error handling function must be specified.");if("function"!=typeof e)return void f(null,"error","A success callback function must be specified.");if(void 0===b)return void f(null,"error","A URL must be specified.");b=String(b);var g=rt.config.proxyBaseURL,h=this.isCrossDomain(b);if(d===!0&&h&&this.isCrossDomain(g))return void f(null,"error","Synchronous downloading not possible");if("boolean"!=typeof d)return void f(null,"error","The sync option must be a boolean, not a "+typeof d);if(h){var i="crossDomainCallback"+Math.floor(9007199254740991*Math.random());return window[i]=function(a){try{if(a.success){var b,d=a.success,g=!1;switch(c){case"text":b=d;break;case"json":try{b=JSON.parse(d)}catch(h){f(null,"parserror",h),g=!0}break;default:f(null,"error","No cross-domain interpretation available for data type "+c),g=!0}g||e(b,"success",null)}else f(null,"error",a.error)}finally{delete window[i]}},$.ajax({url:g+"?url="+encodeURI(b)+"&callback="+i,dataType:"script",async:!d,error:f})}return a.async=!d,$.ajax(a)};var root,eden,edenUI,doneLoading;"isInteger"in Number||(Number.isInteger=function(a){return parseInt(a)===a});var doingNavigateAway=!1,confirmUnload=function(a){if(!doingNavigateAway){eden.project.localSave();var b="Leaving this page will discard the current script. Your work will not be saved.";return a.returnValue=b,b}};EdenStream.prototype.pushPosition=function(){this.position_stack.push(this.position)},EdenStream.prototype.popPosition=function(){this.position=this.position_stack.pop()},EdenStream.prototype.discardPosition=function(){this.position_stack.pop()},EdenStream.prototype.get=function(){return this.position=this.code.length?0:this.code.charCodeAt(this.position+1)},EdenStream.prototype.peek3=function(){return this.position+2>=this.code.length?0:this.code.charCodeAt(this.position+2)},EdenStream.prototype.readLine=function(){var a=this.code.indexOf("\n",this.position);if(a==-1){var b=this.code.substring(this.position);return this.position=this.code.length,b}var b=this.code.substring(this.position,a+1);return this.position=a+1,this.line++,b},EdenStream.prototype.peekLine=function(){var a=this.code.indexOf("\n",this.position);if(a==-1){var b=this.code.substring(this.position);return b}var b=this.code.substring(this.position,a+1);return b},EdenStream.prototype.move=function(a){this.position=a},EdenStream.prototype.reset=function(){this.position=0,this.position_stack=[0],this.prevposition=0,this.line=1},EdenStream.prototype.tokenText=function(){return this.code.substr(this.prevposition,this.position-this.prevposition)},EdenStream.prototype.isBEOL=function(){if(10==this.peek2())return!0;for(var a=this.prevposition-1,b=this.code.charCodeAt(a);9==b||32==b;)a--,b=this.code.charCodeAt(a);return 10==b},EdenStream.prototype.skip=function(){this.position++},EdenStream.prototype.eof=function(){return this.position>=this.code.length},EdenStream.prototype.valid=function(){return this.position=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||95==a||a>=128},EdenStream.prototype.isNumeric=function(a){return a>=48&&a<=57},EdenStream.prototype.tokenType=function(a){return"OBSERVABLE"==a?"identifier":"JAVASCRIPT"==a?"javascript":"NUMBER"==a?"number":"STRING"==a?"string":"CHARACTER"==a?"character":"BOOLEAN"==a?"boolean":"string"!=typeof a?(console.error(a),"INVALID"):this.isAlphaNumeric(a.charCodeAt(0))?"keyword":"("==a||"["==a||"{"==a?"openbracket":")"==a||"]"==a||"}"==a?"closebracket":","==a||"."==a||";"==a||":"==a?"separator":"operator"},EdenStream.prototype.parseAlphaNumeric=function(a){var b="";if(0==this.isAlphaNumeric(this.peek()))return!1;for(;this.valid()&&this.isAlphaNumeric(this.peek());)b+=String.fromCharCode(this.get());return a.value=b,!0},EdenStream.prototype.parseString=function(a,b){for(var c="";this.valid()&&this.peek()!=b;){var d=String.fromCharCode(this.get());if("\n"==d)return this.unget(),a.error=!0,void(a.value="LINEBREAK");"\\"==d?(d=String.fromCharCode(this.get()),c+="\\"+d):c+=d}this.valid()&&this.peek()==b?(this.skip(),a.error=!1):a.error=!0,a.value=c},EdenStream.prototype.parseCharacter=function(a){var b=String.fromCharCode(this.get());return"'"==b?(a.value="",void(a.error=!0)):("\\"==b&&(b=String.fromCharCode(this.get())),a.value=b,void(this.valid()&&39==this.peek()?this.skip():a.error=!0))},EdenStream.prototype.parseNumber=function(a){for(var b="";this.valid()&&this.isNumeric(this.peek());)b+=String.fromCharCode(this.get());if(46==this.peek()&&this.isNumeric(this.peek2()))for(this.skip(),b+=".";this.valid()&&this.isNumeric(this.peek());)b+=String.fromCharCode(this.get());a.value=parseFloat(b)},EdenStream.prototype.readToken=function(a){if(this.prevline=this.line,this.skipWhiteSpace(),this.prevposition=this.position,this.eof())return"EOF";var b=this.code.charCodeAt(this.position);switch(this.position++,b){case 33:return 61==this.peek()?(this.skip(),"!="):126==this.peek()?(this.skip(),"!~"):"!";case 34:return a?'"':(this.parseString(this.data,34),"STRING");case 35:return 35==this.peek()?(this.skip(),"##"):"#";case 36:return 123==this.peek()&&123==this.peek2()?(this.skip(),this.skip(),"${{"):"$";case 37:return"%";case 38:return 38==this.peek()?(this.skip(),"&&"):61==this.peek()?(this.skip(),"&="):"&";case 39:return a?"'":(this.parseString(this.data,39),"STRING");case 40:return"(";case 41:return")";case 42:return 61==this.peek()?(this.skip(),"*="):47==this.peek()?(this.skip(),"*/"):"*";case 43:return 43==this.peek()?(this.skip(),"++"):61==this.peek()?(this.skip(),"+="):"+";case 44:return",";case 45:return 45==this.peek()?(this.skip(),"--"):61==this.peek()?(this.skip(),"-="):"-";case 46:return 46==this.peek()?(this.skip(),".."):".";case 47:return 47==this.peek()&&61==this.peek2()?(this.skip(),"//="):47==this.peek()?(this.skip(),"//"):61==this.peek()?(this.skip(),"/="):42==this.peek()?(this.skip(),"/*"):"/";case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.unget(),this.parseNumber(this.data),"NUMBER";case 58:return 58==this.peek()?(this.skip(),"::"):":";case 59:return";";case 60:return 60==this.peek()?(this.skip(),"<<"):61==this.peek()?(this.skip(),"<="):"<";case 61:return 61==this.peek()?(this.skip(),"=="):126==this.peek()?(this.skip(),"=~"):"=";case 62:return 62==this.peek()?(this.skip(),">>"):61==this.peek()?(this.skip(),">="):">";case 63:return"?";case 64:return"@";case 91:return"[";case 92:return'"';case 93:return"]";case 94:return"^";case 96:return"`";case 123:return"{";case 124:return 124==this.peek()?(this.skip(),"||"):61==this.peek()?(this.skip(),"|="):"|";case 125:return 125==this.peek()&&36==this.peek2()?(this.skip(),this.skip(),"}}$"):"}";case 126:return 62==this.peek()?(this.skip(),"~>"):"~"}if(this.unget(),this.parseAlphaNumeric(this.data))return Language.keywords.hasOwnProperty(this.data.value)?Language.keywords[this.data.value]:Language.values.hasOwnProperty(this.data.value)?(this.data.value=Language.values[this.data.value],"BOOLEAN"):"OBSERVABLE";throw this.skip(),new Error("Invalid Token: "+b)},"undefined"!=typeof require&&"undefined"!=typeof exports&&(exports.EdenStream=EdenStream,exports.EdenSyntaxData=EdenSyntaxData),Eden.SyntaxError=function(a,b,c){this.type="syntax",this.context=a,this.errno=b,this.extra=c,this.token=a.token,this.prevtoken=a.previous,this.line=a.stream.prevline,this.position=a.stream.position,this.prevposition=a.stream.prevposition},Eden.SyntaxError.UNKNOWN=0,Eden.SyntaxError.EXPCLOSEBRACKET=1,Eden.SyntaxError.BADFACTOR=2,Eden.SyntaxError.ACTIONCOLON=3,Eden.SyntaxError.ACTIONNOWATCH=4,Eden.SyntaxError.ACTIONCOMMAS=5,Eden.SyntaxError.ACTIONOPEN=6,Eden.SyntaxError.ACTIONCLOSE=7,Eden.SyntaxError.LOCALNAME=8,Eden.SyntaxError.LOCALSEMICOLON=9,Eden.SyntaxError.WHENTYPE=10,Eden.SyntaxError.LISTINDEXEXP=11,Eden.SyntaxError.LISTINDEXCLOSE=12,Eden.SyntaxError.LVALUE=13,Eden.SyntaxError.SEMICOLON=14,Eden.SyntaxError.STATEMENT=15,Eden.SyntaxError.DEFINITION=16,Eden.SyntaxError.FUNCCALLEND=17,Eden.SyntaxError.LISTLITCLOSE=18,Eden.SyntaxError.TERNIFCOLON=19,Eden.SyntaxError.IFCONDOPEN=20,Eden.SyntaxError.IFCONDCLOSE=21,Eden.SyntaxError.PARAMNAME=22,Eden.SyntaxError.PARAMSEMICOLON=23,Eden.SyntaxError.FUNCOPEN=24,Eden.SyntaxError.FUNCCLOSE=25,Eden.SyntaxError.FUNCNAME=26,Eden.SyntaxError.FOROPEN=27,Eden.SyntaxError.FORCLOSE=28,Eden.SyntaxError.FORSTART=29,Eden.SyntaxError.FORCOND=30,Eden.SyntaxError.SUBSCRIBEOPEN=31,Eden.SyntaxError.SUBSCRIBECLOSE=32,Eden.SyntaxError.SWITCHOPEN=33,Eden.SyntaxError.SWITCHCLOSE=34,Eden.SyntaxError.DEFAULTCOLON=35,Eden.SyntaxError.CASELITERAL=36,Eden.SyntaxError.CASECOLON=37,Eden.SyntaxError.INSERTCOMMA=38,Eden.SyntaxError.DELETECOMMA=39,Eden.SyntaxError.APPENDCOMMA=40,Eden.SyntaxError.SCOPENAME=41,Eden.SyntaxError.SCOPEEQUALS=42,Eden.SyntaxError.SCOPECLOSE=43,Eden.SyntaxError.BACKTICK=44,Eden.SyntaxError.WHILEOPEN=45,Eden.SyntaxError.WHILECLOSE=46,Eden.SyntaxError.WHILENOSTATEMENT=47,Eden.SyntaxError.NEGNUMBER=48,Eden.SyntaxError.DEFINELISTIX=49,Eden.SyntaxError.OUTOFBOUNDS=50,Eden.SyntaxError.PROPERTYNAME=51,Eden.SyntaxError.WHILEOFDO=52,Eden.SyntaxError.PARAMNUMBER=53,Eden.SyntaxError.AFTEROPEN=55,Eden.SyntaxError.AFTERCLOSE=56,Eden.SyntaxError.ACTIONNAME=57,Eden.SyntaxError.WHENOPEN=58,Eden.SyntaxError.WHENCLOSE=59,Eden.SyntaxError.DONAME=60,Eden.SyntaxError.PROCNAME=61,Eden.SyntaxError.IMPORTPATH=62,Eden.SyntaxError.IMPORTOPTION=63,Eden.SyntaxError.IMPORTCOMB=64,Eden.SyntaxError.IFNOSTATEMENT=65,Eden.SyntaxError.AFTERNOSTATEMENT=66,Eden.SyntaxError.WHENNOSTATEMENT=67,Eden.SyntaxError.LITCHAREMPTY=68,Eden.SyntaxError.LITCHARCLOSE=69,Eden.SyntaxError.LITSTRLINE=70,Eden.SyntaxError.LITSTRCLOSE=71,Eden.SyntaxError.IMPORTTAG=72,Eden.SyntaxError.SWITCHSCRIPT=73,Eden.SyntaxError.RANGEBANNED=74,Eden.SyntaxError.HEREDOCTOKEN=75,Eden.SyntaxError.SELECTORACTION=76,Eden.SyntaxError.SELECTORATTRIB=77,Eden.SyntaxError.SELECTORTAG=78,Eden.SyntaxError.SELECTORBTICK=79,Eden.SyntaxError.SELECTOROPTION=80,Eden.SyntaxError.QUERYOPEN=81,Eden.SyntaxError.QUERYCLOSE=82,Eden.SyntaxError.QUERYSELECTOPEN=83,Eden.SyntaxError.QUERYSELECTCLOSE=84,Eden.SyntaxError.QUERYSELECTCOMMA=85,Eden.SyntaxError.BLOCKCOMMENT=86,Eden.SyntaxError.NEWLINE=87,Eden.SyntaxError.db=[{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return"}"==this.token||"]"==this.token?0:";"==this.token?1:2},suggestion:{expected:[")"],next:[";","+","-","==","<=",">=","!=","/","*","%","^"]}},{message:function(){if("{"==this.token)return 0;if(")"==this.token){var a=this.context.stream.tokenType(this.prevtoken);return"operator"==a?3:1}var b=this.context.stream.tokenType(this.token);return"keyword"==b?4:"operator"==b?3:2},suggestion:{expected:["NUMBER","STRING","OBSERVABLE","&","!","("],next:["NUMBER","STRING","OBSERVABLE","&","!","(",";","+","-","==","<=",">=","!=","/","*","%","^"]}},{message:function(){if("{"==this.token)return 1;if("OBSERVABLE"==this.token)return 0;var a=this.context.stream.tokenType(this.token);return"keyword"==a?3:2},suggestion:{expected:[":"],next:["OBSERVABLE"]}},{message:function(){if("{"==this.token)return 2;if("("==this.token)return 3;if("["==this.token&&(":"==this.prevtoken||","==this.prevtoken))return 6;if("NUMBER"==this.token||"STRING"==this.token)return 4;if(","==this.token)return 5;var a=this.context.stream.tokenType(this.token);return"keyword"==a?0:1},suggestion:{expected:["OBSERVABLE"],next:[",","{"]}},{message:function(){if("{"==this.token)return 0;if("("==this.token&&!this.context.stream.isBEOL())return 1;var a=this.context.stream.tokenType(this.token);return"keyword"==a?2:3},suggestion:{expected:["OBSERVABLE"],next:[",","{"]}},{message:function(){if(("("==this.token||"["==this.token)&&this.context.stream.isBEOL())return 6;if("("==this.token)return 0;if("["==this.token)return 1;if(";"==this.token)return 2;var a=this.context.stream.tokenType(this.token);return"keyword"==a||"identifier"==a?3:"separator"==a?4:5},suggestion:{expected:["{"],next:["local","OBSERVABLE","if","for","switch","while","return"]}},{message:function(){return(")"==this.token||"]"==this.token)&&this.context.stream.isBEOL()?0:1},suggestion:{expected:["}"],next:["proc","func","if","for","OBSERVABLE","switch","while","return","continue","break"]}},{message:function(){var a=this.context.stream.tokenType(this.token);return"keyword"==a?0:";"==this.token?1:2},suggestion:{expected:["OBSERVABLE"],next:[";"]}},{message:function(){return"is"==this.token||"="==this.token?1:0},suggestion:{expected:[";"],next:["local","OBSERVABLE","if","for","switch","while","return"]}},{message:function(){return 0},suggestion:{expected:["touch","change","("],next:["OBSERVABLE",":","NUMBER","STRING","!","&"]}},{message:function(){return 0},suggestion:{expected:["(","OBSERVABLE","NUMBER"],next:["]","OBSERVABLE","NUMBER","+","-","/","*","%","^"]}},{message:function(){return 1},suggestion:{expected:["]"],next:["[",".","=","+=","-=","==","+","-","/","*",";","/=","*=","%","^","is"]}},{message:function(){return 0},suggestion:{expected:["OBSERVABLE"],next:[".","[","is","=","+=","-=","++","--","*=","/="]}},{message:function(){if("."==this.token){var a=this.position>=2?this.context.stream.code.charCodeAt(this.position-2):0;return"NUMBER"==this.prevtoken&&32!=a&&160!=a?1:2}return"OBSERVABLE"==this.token?this.context.stream.isBEOL()?3:4:0},suggestion:{expected:[";"],next:["proc","when","OBSERVABLE","if","for","while","EOF","switch","func"]}},{message:function(){return 0},suggestion:{expected:["proc","func","when","if","for","while","switch","OBSERVABLE","{"],next:["OBSERVABLE","(","change","touch","is","=","+=","-=","*=","proc","func","when","if","for","while","switch"]}},{message:function(){return 0},suggestion:{expected:["=","is","+=","-=","/=","*="],next:["(","OBSERVABLE","NUMBER","STRING","!"]}},{message:function(){return 0},suggestion:{expected:[")"],next:[";","(","[","+","-","/","*","%","^"]}},{message:function(){return 0},suggestion:{expected:["]"],next:[]}},{message:function(){return 0},suggestion:{expected:[":"],next:[]}},{message:function(){return 0},suggestion:{expected:["("],next:[]}},{message:function(){return 0},suggestion:{expected:[")"],next:[]}},{message:function(){return 0},suggestion:{expected:["OBSERVABLE"],next:[";"]}},{message:function(){return 0},suggestion:{expected:[";"],next:["para","local","OBSERVABLE","if","for","switch","while","return"]}},{message:function(){if(("("==this.token||"["==this.token)&&this.context.stream.isBEOL())return 6;if("("==this.token)return 0;if("["==this.token)return 1;if(";"==this.token)return 2;var a=this.context.stream.tokenType(this.token);return"keyword"==a||"identifier"==a?3:"separator"==a?4:5},suggestion:{expected:["{"],next:["local","OBSERVABLE","if","for","switch","while","return"]}},{message:function(){return 0},suggestion:{expected:["}"],next:[";"]}},{message:function(){return 0},suggestion:{expected:["OBSERVABLE"],next:["{"]}},{message:function(){return 0},suggestion:{expected:["("],next:[]}},{message:function(){return 0},suggestion:{expected:[")"],next:[]}},{message:function(){return 0},suggestion:{expected:[";"],next:[]}},{message:function(){return 0},suggestion:{expected:[";"],next:[]}},{message:function(){return 0},suggestion:{expected:["["],next:[]}},{message:function(){return 0},suggestion:{expected:["]"],next:[]}},{message:function(){return 0},suggestion:{expected:["("],next:[]}},{message:function(){return 0},suggestion:{expected:["]"],next:[]}},{message:function(){return 0},suggestion:{expected:[":"],next:[]}},{message:function(){return 0},suggestion:{expected:["NUMBER","STRING"],next:[]}},{message:function(){return 0},suggestion:{expected:[":"],next:[]}},{message:function(){return 0},suggestion:{expected:[","],next:[]}},{message:function(){return 0},suggestion:{expected:[","],next:[]}},{message:function(){return 0},suggestion:{expected:[","],next:[]}},{message:function(){return 0},suggestion:{expected:["OBSERVABLE"],next:[]}},{message:function(){return 0},suggestion:{expected:["="],next:[]}},{message:function(){return 0},suggestion:{expected:["}"],next:[]}},{message:function(){return 0},suggestion:{expected:["`"],next:[]}},{message:function(){return 0},suggestion:{expected:["("],next:[]}},{message:function(){return 0},suggestion:{expected:[")"],next:[]}},{message:function(){return 0},suggestion:{expected:[")"],next:[]}},{message:function(){return 0},suggestion:{expected:["NUMBER"],next:[]}},{message:function(){ -return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){var a=this.context.stream.tokenType(this.token);return"keyword"==a?0:"boolean"==a||"character"==a||"string"==a||"number"==a?1:":"==this.token?4:"{"==this.token?5:"closebracket"==this.token?3:2},suggestion:{expected:["OBSERVABLE"],next:[":"]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}},{message:function(){return 0},suggestion:{expected:[],next:[]}}],Eden.SyntaxError.prototype.extractBefore=function(a){for(var b=this.prevposition;b>0&&a>0&&10!=this.context.stream.code.charCodeAt(b);)b--,a--;return 10==this.context.stream.code.charCodeAt(b)&&b++,this.context.stream.code.substr(b,this.prevposition-b)},Eden.SyntaxError.prototype.extractToken=function(){return this.context.stream.code.substr(this.prevposition,this.position-this.prevposition)},Eden.SyntaxError.prototype.extractAfter=function(a){for(var b=this.position;b0&&10!=this.context.stream.code.charCodeAt(b);)b++,a--;return this.context.stream.code.substr(this.position,b-this.position)},Eden.SyntaxError.prototype.buildSuggestion=function(){var a=Eden.SyntaxError.db[this.errno].suggestion;return a.next.indexOf(this.token)!=-1?this.extractBefore(10)+a.expected[0]+" "+this.extractToken()+this.extractAfter(10):this.extractBefore(10)+a.expected[0]+" "+this.extractAfter(10)},Eden.SyntaxError.prototype.messageText=function(){var a=Eden.SyntaxError.db[this.errno],b=Language.errors[this.errno][a.message.call(this)];return void 0===this.extra?b:b+": "+this.extra},Eden.SyntaxError.prototype.prettyPrint=function(){this.context.stream.pushPosition(),this.context.stream.move(this.position);var a=Eden.SyntaxError.db[this.errno],b=Language.errors[this.errno][a.message.call(this)],c="Error:\n "+b+"\n Source : "+this.context.src+", line "+this.line+"\n Code : "+this.errno;return c+="\n Here : "+this.extractBefore(10)+">>> "+this.extractToken()+" <<<"+this.extractAfter(10),a.suggestion&&(c+="\n Suggestion : "+this.buildSuggestion()),this.context.stream.popPosition(),c},Eden.SyntaxError.prototype.toString=function(){return this.prettyPrint()},Eden.RuntimeError=function(a,b,c,d){this.type="runtime",this.line=-1,this.statement=c,this.extra=d,this.errno=b,this.context=a,this.lastsymbol=eden.root.lastlookup,console.error(d)},Eden.RuntimeError.UNKNOWN=0,Eden.RuntimeError.ASSIGNEXEC=1,Eden.RuntimeError.FUNCCALL=2,Eden.RuntimeError.ACTIONNAME=3,Eden.RuntimeError.NOAGENT=4,Eden.RuntimeError.NOTSUPPORTED=5,Eden.RuntimeError.ASSIGNTODEFINED=6,Eden.RuntimeError.ASSIGNDIMENSION=7,Eden.RuntimeError.EXTENDSTATIC=8,Eden.RuntimeError.INFINITERANGE=9,Eden.RuntimeError.NOLISTRANGE=10,Eden.RuntimeError.LEFTCONCAT=11,Eden.RuntimeError.RIGHTCONCAT=12,Eden.RuntimeError.AGENTSOURCE=13,Eden.RuntimeError.JSOBSERVER=14,Eden.RuntimeError.PROCAGENT=15,Eden.RuntimeError.ARGUMENTS=16,Eden.RuntimeError.NOTCHILD=17,Eden.RuntimeError.prototype.messageText=function(){var a=!this.statement||"functioncall"!=this.statement.type&&"definition"!=this.statement.type&&"assignment"!=this.statement.type?"":"'"+this.statement.lvalue.name+"': ";switch(this.errno){case Eden.RuntimeError.ACTIONNAME:case Eden.RuntimeError.NOAGENT:case Eden.RuntimeError.NOTSUPPORTED:case Eden.RuntimeError.AGENTSOURCE:case Eden.RuntimeError.JSOBSERVER:case Eden.RuntimeError.PROCAGENT:case Eden.RuntimeError.ARGUMENTS:case Eden.RuntimeError.EXTENDSTATIC:return a+this.extra;case Eden.RuntimeError.ASSIGNTODEFINED:return a+"cannot assign to a defined list, use 'is'";case Eden.RuntimeError.ASSIGNDIMENSION:return a+"list does not have this many dimensions";case Eden.RuntimeError.RIGHTCONCAT:return a+"Concatenation: When the right hand side is a list then the left hand side must also be a list";case Eden.RuntimeError.LEFTCONCAT:return a+"Concatenation: When the left hand side is a list then the right hand side must also be a list";case Eden.RuntimeError.INFINITERANGE:return a+"range scope is infinite";case Eden.RuntimeError.NOLISTRANGE:return a+"range 'in' is not a list"}return String(this.extra).search("is not a function")>=0?a+"function used does not exist":this.errno==Eden.RuntimeError.FUNCCALL&&String(this.extra).search("Cannot read property 'call'")>=0?a+"procedure does not exist":String(this.extra).match(/Cannot read property .* of undefined/)?a+"uses an undefined list":this.extra},Eden.RuntimeError.prototype.edenSource=function(){if(this.statement)if("definition"==this.statement.type){var a=eden.root.symbols[this.statement.lvalue.name];if(a&&a.definition)return a.getSource()}else if(this.context)return this.context.getSource(this.statement)},Eden.RuntimeError.prototype.javascriptSource=function(){return this.statement.generate({scopes:[],dependencies:{}},"scope")},Eden.RuntimeError.prototype.details=function(){var a="";return"definition"!=this.statement.type&&"assignment"!=this.statement.type||(a+="Symbol: "+this.statement.lvalue.name+"\n"),a+=String(this.extra).search("SyntaxError")>=0?"JavaScript: "+this.javascriptSource()+"\n":"Source: "+this.edenSource()+"\n",this.extra.message&&(a+="Original: "+this.extra.message+"\n"),a},Eden.RuntimeError.prototype.prettyPrint=function(){return this.extra&&this.extra.stack?"Run-time Error:\n"+this.extra.stack:"Run-time Error:\n"},Eden.Selectors={cache:{}},Eden.Selectors.getScriptBase=function(a){for(var b=a;b.parent;)b=b.parent;return b.base.origin.name},Eden.Selectors.buildScriptTree=function(a){for(var b={},c=0;c ")},Eden.Selectors.getPath=function(a){},Eden.Selectors.testType=function(a){if("binaryop"==a.type)switch(a.op){case"+":case"-":case"/":case"*":case"^":case"%":return"number";case"//":return"list";case"==":case"<":case">":case"<=":case">=":case"||":case"&&":case"!=":return"boolean";default:return"unknown"}else if("literal"==a.type)switch(a.datatype){case"NUMBER":return"number";case"BOOLEAN":return"boolean";case"STRING":return"string";case"LIST":return"list";default:return"unknown"}return"unknown"},Eden.Selectors.getChildren=function(a,b){var c=[];if(void 0===a)return c;for(var d=0;da[d].depth);)"dummy"!=e.type&&(c.push(e),f.push(e)),e=e.nextSibling;b&&c.push.apply(c,Eden.Selectors.getChildren(f,b))}return c=c.filter(function(a){return"dummy"!=a.type})},Eden.Selectors.allowedOptions={external:!0,history:!0,all:!0,indexed:!0,index:!0,nosort:!0,remote:!0},Eden.Selectors.resultTypes={brief:!0,comment:!0,source:!0,innersource:!0,title:!0,path:!0,name:!0,symbol:!0,line:!0,depends:!0,value:!0,tags:!0,rawcomment:!0,id:!0,remote:!0,root:!0,enabled:!0,executed:!0,exprtree:!0},Eden.Selectors.expressionToLists=function(a){switch(a.type){case"binaryop":return[Eden.Selectors.expressionToLists(a.l),a.op,Eden.Selectors.expressionToLists(a.r)];case"ternaryop":return[Eden.Selectors.expressionToLists(a.first),"if",Eden.Selectors.expressionToLists(a.condition),"else",Eden.Selectors.expressionToLists(a.second)];case"unaryop":return[a.op,Eden.Selectors.expressionToLists(a.r)];case"length":return[Eden.Selectors.expressionToLists(a.l),"#"];case"index":return Eden.Selectors.expressionToLists(a.expression)}if(console.log(a),"functioncall"==a.type){console.log("FUNCCALL");for(var b=[],c=0;c0;break;case"historic":i=f.executed==-1;break;case"tags":f.doxyComment&&(i=f.doxyComment.getHashTags());break;case"rawcomment":f.doxyComment&&(i=f.doxyComment.content);break;case"controls":case"id":i=f.id;break;case"path":i=Eden.Selectors.getID(f);break;case"remote":for(var l=f;l.parent;)l=l.parent;if(!l.base||!l.base.origin){i=!1;break}i=l.base.origin.remote;break;case"root":i=void 0===f.parent}g.push(i)}c.length>1?d.push(g):1==c.length&&g.length>0&&d.push(g[0])}return d}return a},Eden.Selectors.outerBracket=function(a){for(var b=0,c=0;c0&&"@"==a.charAt(0);){c||(c={}),a=a.substring(1);var d=a.search(/[^a-z]+/);d==-1&&(d=a.length);var e=a.substring(0,d);a=a.substring(d).trim(),c[e]=!0}return Eden.Selectors._parse(a,c)}},Eden.Selectors._parse=function(a,b){var c;if(a&&""!=a){if(">"==a.charAt(0))">"==a.charAt(1)?(c=new Eden.Selectors.NavigateNode(">",(!0)),a=a.substring(2).trim()):(c=new Eden.Selectors.NavigateNode(">",(!1)),a=a.substring(1).trim());else if("<"==a.charAt(0))"<"==a.charAt(1)?(c=new Eden.Selectors.NavigateNode("<",(!0)),a=a.substring(2).trim()):(c=new Eden.Selectors.NavigateNode("<",(!1)),a=a.substring(1).trim());else if(","==a.charAt(0))c=new Eden.Selectors.UnionNode,a=a.substring(1).trim();else if(":"==a.charAt(0)||"."==a.charAt(0)){var d=a.substring(1),e=d.search(/[^a-zA-Z0-9\-]/);e==-1?e=a.length:e++;var f=a.substring(0,e),g=void 0;if(e]/);j==-1&&(j=a.length);var k=a.substring(0,j).trim();if(k.startsWith("plugins")){for(var l=a.split(">"),m="",n=0;n0){for(var c=0;c0?c(0):b&&b()})},Eden.Selectors.goto=function(a){Eden.Selectors.query(a,void 0,{minimum:1,noindex:!0},function(b){if(0==b.length)return!1;for(var c=[b[0]],d=b[0];d.parent;)c.push(d.parent),d=d.parent;for(var e=!1,f=0;f":this.compare="="==b.charAt(1)?">=":">";break;case"=":this.compare="=";break;case"!":this.compare="!="}if(this.compare)switch(this.compare){case"!":case"=":case">":case"<":this.value=b.substring(1);break;case">=":case"<=":this.value=b.substring(2)}if(this.isreg?this.value=Eden.Selectors.makeRegex(this.value):null!==b.match(/^[0-9]+\-[0-9]+$/)?this.range=!0:null!==b.match(/^[0-9]+$/)&&(this.value=parseInt(b)),".type"==this.name)switch(this.param){case"is":this.param="definition";break;case"assign":case"=":this.param="assignment";break;case"call":this.param="functioncall";break;case"proc":this.param="action";break;case"action":this.param="script";break;case"+=":case"-=":case"*=":case"/=":case"++":case"--":this.param="modify"}}},Eden.Selectors.PropertyNode.attributes={name:{local:!1,indexed:!0,rank:1},type:{local:!1,indexed:!1,rank:3},datatype:{local:!1,indexed:!1,rank:30},id:{local:!1,indexed:!0,rank:2},lines:{local:!1,indexed:!1,rank:3},depends:{local:!1,indexed:!1,rank:4},time:{local:!0,indexed:!1,rank:3},date:{local:!1,indexed:!1,rank:3},title:{local:!1,indexed:!1,rank:10},author:{local:!1,indexed:!1,rank:10},v:{local:!1,indexed:!1,rank:20},version:{local:!1,indexed:!1,rank:20},source:{local:!0,indexed:!1,rank:50},comment:{local:!0,indexed:!1,rank:50}},Eden.Selectors.PropertyNode.pseudo={line:{local:!1,indexed:!1,rank:50},determines:{local:!0,indexed:!0,rank:10},first:{local:!1,indexed:!0,rank:5},last:{local:!1,indexed:!0,rank:5},unexecuted:{local:!0,indexed:!1,rank:3},executed:{local:!0,indexed:!1,rank:3},root:{local:!1,indexed:!0,rank:3},project:{local:!0,indexed:!0,rank:3},nth:{local:!1,indexed:!0,rank:5},value:{local:!0,indexed:!1,rank:50},matches:{local:!1,indexed:!1,rank:100},age:{local:!1,indexed:!1,rank:6},remote:{local:!0,indexed:!0,rank:20},not:{local:!1,indexed:!1,rank:100},active:{local:!0,indexed:!1,rank:10},me:{local:!1,indexed:!1,rank:20},listed:{local:!1,indexed:!1,rank:20}},Eden.Selectors.PropertyNode.prototype.append=function(a){if(!a)return this;switch(a.type){case"property":case"tag":case"name":var b=new Eden.Selectors.IntersectionNode(this,a);return b.options=this.options,b;case"union":case"intersection":return a.prepend(this),a;case"navigate":return a.prepend(this),a}return this},Eden.Selectors.PropertyNode.prototype.prepend=function(a){if(!a)return this;switch(a.type){case"property":case"tag":case"name":var b=new Eden.Selectors.IntersectionNode(a,this);return b.options=this.options,b;case"union":case"intersection":return a.append(this),a;case"navigate":return a.append(this),a}return this},Eden.Selectors.PropertyNode.prototype.filter=function(a){a||(a=this.construct());var b=this,c=this.value,d=this.name;if("number"==typeof this.name)return a&&a.length>=this.name?[a[this.name-1]]:[];switch(d){case".name":if(!c)return a.filter(function(a){return void 0!==a.lvalue||void 0!==a.name});var e=edenUI.regExpFromStr(c);return a.filter(function(a){return a.lvalue&&e.test(a.lvalue.name)||a.name&&e.test(a.name)});case".id":return a.filter(function(a){return 0==a.id&&a.buildID(),a.id==c});case".type":if(!c)break;return a.filter(function(a){return a.type==c});case".datatype":return a.filter(function(a){return a.expression&&Eden.Selectors.testType(a.expression)==c||a.expression&&"scope"==a.expression.type&&a.expression.range&&"list"==c});case".lines":return a;case":line":return a;case".op":case".operator":return a;case":pattern":return a;case":determines":return a;case".depends":return a.filter(function(a){return("definition"==a.type||"when"==a.type)&&a.dependencies[c]});case":active":return a.filter(function(a){if("definition"==a.type||"assignment"==a.type){var b=eden.root.symbols[a.lvalue.name];return b&&(b.origin===a||b.origin&&b.origin.id==a.id)}return"when"==a.type&&a.enabled});case":first":return a.length>0?[a[0]]:[];case":last":return a.length>0?[a[a.length-1]]:[];case":unexecuted":return a.filter(function(a){return 0==a.executed});case":executed":return a.filter(function(a){return 1==a.executed});case":root":return a.filter(function(a){return void 0===a.parent});case":project":return[eden.project.ast.script];case":nth":return a.filter(function(a){return a.parent&&Eden.Selectors.getChildren([a.parent],!1)[b.value-1]===a});case":value":return a;case":":case":matches":var f=Eden.Selectors.parse(this.param);return f?f.filter(a):[];case".title":return this.isreg?a.filter(function(a){if(!a.doxyComment)return!1;var c=a.doxyComment.getProperty("title");return c&&b.value.test(c)}):a.filter(function(a){if(!a.doxyComment)return!1;var c=a.doxyComment.getProperty("title");return c&&c==b.value});case".author":return a;case".version":return a;case".source":return this.isreg?a.filter(function(a){return b.value.test(a.getSource())}):a.filter(function(a){return a.getSource()==b.value});case".comment":return this.isreg?a.filter(function(a){return a.doxyComment&&b.value.test(a.doxyComment.stripped())}):a.filter(function(a){return a.doxyComment&&a.doxyComment.stripped()==b.value});case":age":var g=generateTimeStamp(this.value),h=Date.now(),i=h-g;return console.log("AGE",g,h,i),void 0===this.compare||"<"==this.compare?a.filter(function(a){return a.stamp>i}):a.filter(function(a){return a.stamp=0})},Eden.Selectors.NameNode=function(a){this.type="name",this.name=a,this.options=void 0,this.isreg="/"==a.charAt(0)||a.indexOf("*")!=-1,this.local=!1},Eden.Selectors.NameNode.prototype.filter=function(a){if(!a)return this.construct();var b=this.name;if(this.isreg){var c=Eden.Selectors.makeRegex(this.name);return a.filter(function(a){return a.lvalue&&c.test(a.lvalue.name)||a.name&&c.test(a.name)})}return a.filter(function(a){return a.lvalue&&a.lvalue.name==b||a.name&&a.name==b})},Eden.Selectors.NameNode.prototype.construct=function(){if(this.isreg){var a=Eden.Selectors.makeRegex(this.name);stats=Eden.Index.getByNameRegex(a)}else{stats=Eden.Index.getByName(this.name);for(var b=this.name.toLowerCase().split(" "),c=Eden.Index.getByTag("#"+b[0]),d=1;d=0})},Eden.Selectors.NameNode.prototype.append=Eden.Selectors.PropertyNode.prototype.append,Eden.Selectors.NameNode.prototype.prepend=Eden.Selectors.PropertyNode.prototype.prepend,Eden.Selectors.TagNode=function(a){this.type="tag",this.tag=a,this.options=void 0,this.isreg=a.indexOf("*")!=-1,this.local=!1},Eden.Selectors.TagNode.prototype.filter=function(a){if(!a)return this.construct();var b=this;return a.filter(function(a){return a.doxyComment&&a.doxyComment.hasTag(b.tag)})},Eden.Selectors.TagNode.prototype.construct=function(){if(this.isreg){var a=Eden.Selectors.makeRegex(this.tag);stats=Eden.Index.getByTagRegex(a)}else stats=Eden.Index.getByTag(this.tag);return this.options&&this.options.history?stats:stats.filter(function(a){return a.executed>=0})},Eden.Selectors.TagNode.prototype.append=Eden.Selectors.PropertyNode.prototype.append,Eden.Selectors.TagNode.prototype.prepend=Eden.Selectors.PropertyNode.prototype.prepend,Eden.Selectors.IntersectionNode=function(a,b){this.type="intersection",this.children=[a,b],this.local=!1},Eden.Selectors.IntersectionNode.prototype.append=function(a){if(!a)return this;switch(a.local&&(this.local=!0),a.type){case"navigate":return a.prepend(this), -a}return this.children.push(a),this},Eden.Selectors.IntersectionNode.prototype.prepend=function(a){return a?(a.local&&(this.local=!0),this.children.splice(0,0,a),this):this},Eden.Selectors.IntersectionNode.prototype.filter=function(a,b){for(var c=0;c"==this.direction){if(!a&&void 0===this.left)return this.right?this.right.filter(a,b).filter(function(a){return void 0!==a.parent}):Eden.Index.getAll().filter(function(a){return void 0!==a.parent});var c;return c=void 0===this.left?Eden.Selectors.getChildren(a,this.deep):Eden.Selectors.getChildren(this.left.filter(a,b),this.deep),this.right?this.right.filter(c,b):c}if("<"==this.direction){if(!a&&void 0===this.left)return this.right?this.right.filter(a,b).filter(function(a){return"script"==a.type||"when"==a.type||"if"==a.type||"for"==a.type}):Eden.Index.getAll().filter(function(a){return"script"==a.type||"when"==a.type||"if"==a.type||"for"==a.type});var c;if(c=void 0===this.left?a.filter(function(a){return"script"==a.type||"when"==a.type||"if"==a.type||"for"==a.type}):this.left.filter(a,b),this.deep){for(var d=[],e=0;e=0&&Eden.Index.name_index[d].splice(e,1)}if(a.tags)for(var f=a.tags,c=0;c=0&&Eden.Index.tag_index[f[c]].splice(e,1)}}}},Eden.Index.update=function(a){if(void 0===Eden.Index.id_index[a.id]&&(Eden.Index.id_index[a.id]=[]),Eden.Index.id_index[a.id].push(a),1==Eden.Index.id_index[a.id].length){if(void 0===Eden.Index.type_index[a.type]&&(Eden.Index.type_index[a.type]={}),Eden.Index.type_index[a.type][a.id]=!0,a.name&&"do"!=a.type||a.lvalue){var b=a.name?a.name:a.lvalue.name;void 0===Eden.Index.name_index[b]&&(Eden.Index.name_index[b]=[]),Eden.Index.name_index[b].indexOf(a.id)==-1&&Eden.Index.name_index[b].push(a.id)}if(a.tags)for(var c=a.tags,d=0;d0&&this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.debug=!1,Eden.AST.debugstep=!1,Eden.AST.debugstep_cb=void 0,Eden.AST.debugspeed=500,Eden.AST.debugbreakpoint=void 0,Eden.AST.debugbreakpoint_cb=void 0,Eden.AST.debug_begin_cb=void 0,Eden.AST.debug_end_cb=void 0,Eden.AST.fromNode=function(a,b){var c=new Eden.AST(a.getInnerSource(),(void 0),b,{noindex:!0,noparse:!0});return c.script=a,c.whens=Eden.Selectors.queryWithin([a],">>.type(when)"),c.errors=a.errors,c},Eden.AST.prototype.doxyFromOrigin=function(){var a=this.origin.name;if(this.origin.title&&(a+="\n * @title "+this.origin.title),this.origin.author&&(a+="\n * @author "+this.origin.author),this.origin.id&&(a+="\n * @id "+this.origin.id),this.origin.saveID&&(a+="\n * @version "+this.origin.vid),this.origin.tags&&this.origin.tags.length>0){a+="\n *";for(var b=0;b>"),b=0;b0&&(this.lines[a].executed=0)},Eden.AST.prototype.executeLine=function(a,b,c){var d,e=a;d=a==-1?this.script:this.lines[e],void 0!==d&&(d=this.getBase(d),this.executeStatement(d,e,b,c))},Eden.AST.parseStatement=function(a,b){var c=new Eden.AST(a,(void 0),b?b:{},{noparse:!0,noindex:!0});c.next();var d=c.pSTATEMENT();d.base=c,d.setSource(0,a.length,a),d.stamp=c.stamp;var e=a.match("\n");return null===e?d.numlines=0:d.numlines=e.length,d},Eden.AST.parseScript=function(a,b){var c=new Eden.AST(a,(void 0),b?b:{},{noparse:!0,noindex:!0});c.next();var d=c.pSCRIPT();d.base=c,d.setSource(0,a.length,a),d.stamp=c.stamp;var e=a.match("\n");return null===e?d.numlines=0:d.numlines=e.length,d},Eden.AST.parseExpression=function(a){var b=new Eden.AST(a,(void 0),{},{noparse:!0,noindex:!0});b.next();var c=b.pEXPRESSION();return c},Eden.AST.registerStatement=function(a){a.prototype.getOrigin=Eden.AST.BaseStatement.getOrigin,a.prototype.hasErrors=Eden.AST.BaseStatement.hasErrors,a.prototype.setSource=Eden.AST.BaseStatement.setSource,a.prototype.getSource=Eden.AST.BaseStatement.getSource,a.prototype.getOuterSource=Eden.AST.BaseStatement.getOuterSource,a.prototype.getNumberOfLines=Eden.AST.BaseStatement.getNumberOfLines,a.prototype.getStartLine=Eden.AST.BaseStatement.getStartLine,a.prototype.getEndLine=Eden.AST.BaseStatement.getEndLine,a.prototype.getRange=Eden.AST.BaseStatement.getRange,a.prototype.error=Eden.AST.fnEdenASTerror,a.prototype.addIndex=Eden.AST.BaseStatement.addIndex,a.prototype.removeIndex=Eden.AST.BaseStatement.removeIndex,a.prototype.destroy=Eden.AST.BaseStatement.destroy,a.prototype.buildID=Eden.AST.BaseStatement.buildID,a.prototype.setDoxyComment=Eden.AST.BaseStatement.setDoxyComment},Eden.AST.registerScript=function(a){Eden.AST.registerStatement(a),a.prototype.getStatementByLine=Eden.AST.BaseScript.getStatementByLine,a.prototype.getRelativeLine=Eden.AST.BaseScript.getRelativeLine,a.prototype.getNumberOfLines=Eden.AST.BaseScript.getNumberOfLines,a.prototype.append=Eden.AST.BaseScript.append,a.prototype.appendChild=Eden.AST.BaseScript.appendChild,a.prototype.removeChild=Eden.AST.BaseScript.removeChild,a.prototype.insertBefore=Eden.AST.BaseScript.insertBefore,a.prototype.insertAfter=Eden.AST.BaseScript.insertAfter,a.prototype.replaceChild=Eden.AST.BaseScript.replaceChild,a.prototype.addIndex=Eden.AST.BaseScript.addIndex,a.prototype.removeIndex=Eden.AST.BaseScript.removeIndex,a.prototype.destroy=Eden.AST.BaseScript.destroy,a.prototype.buildID=Eden.AST.BaseScript.buildID},Eden.AST.registerContext=function(a){Eden.AST.registerScript(a)},Eden.AST.prototype.getBase=function(a,b){void 0===b&&console.error("Undefined context in getBase");for(var c=a;c&&c.parent&&c.parent!==b;)c=c.parent;return c},Eden.AST.prototype.getBlockLines=function(a,b){for(var c=a,d=this.getBase(this.lines[c],b);c>0&&this.lines[c-1]&&this.getBase(this.lines[c-1],b)==d;)c--;for(var e=c;c0},Eden.AST.prototype.prettyPrint=function(){var a="";if(this.script.errors.length>0)for(var b=0;b0);)this.token=this.stream.readToken(),"/*"==this.token?b++:"*/"==this.token&&b--;if("*/"!=this.token){var f=new Eden.SyntaxError(this,Eden.SyntaxError.BLOCKCOMMENT);f.line=e,this.errors.push(f)}if(c){var g=new Eden.AST.DoxyComment(this.stream.code.substring(d+3,this.stream.position-2).trim(),e,this.stream.line);this.lastDoxyComment.push(g),g.parent=this.parentDoxy,g.content.endsWith("@{")?this.parentDoxy=g:g.content.startsWith("@}")&&this.parentDoxy&&(this.parentDoxy=this.parentDoxy.parent)}this.token=this.stream.readToken()}else{if("${{"!=this.token)break;var d=this.stream.position,e=this.stream.line;for(this.data.line=e;this.stream.valid()&&"}}$"!=this.token;)this.token=this.stream.readToken();this.data.value=this.stream.code.substring(d,this.stream.position-3),this.token="JAVASCRIPT",this.stream.prevposition=d-3}this.stream.prevline=a},Eden.AST.prototype.peekNext=function(a){var b,c={value:""};for(this.stream.data=c,this.stream.pushPosition();a>0;)b=this.stream.readToken(),a--;return this.stream.popPosition(),this.stream.data=this.data,b},Eden.AST.BaseStatement=function(){this.start=0,this.end=0,this.parent=void 0,this.errors=[],this.warning=void 0,this.executed=0,this.numlines=-1,this.doxyComment=void 0,this.lock=0,this.source=void 0,this.id=0,this.stamp=0,this.nextSibling=void 0,this.previousSibling=void 0,this.tags=void 0},Eden.AST.BaseStatement.setDoxyComment=function(a){this.doxyComment=a,a&&(void 0===this.tags?this.tags=a.getHashTags():this.tags=this.tags.concat(a.getHashTags()))},Eden.AST.BaseStatement.buildID=function(){var a,b=0,c=this.source;this.doxyComment&&(c=this.doxyComment.content+c);for(var d=c.length,e=0;e0},Eden.AST.BaseStatement.getNumberOfLines=function(){return this.numlines},Eden.AST.BaseStatement.getStartLine=function(a){return this.parent?this.parent.getRelativeLine(this,a):-1},Eden.AST.BaseStatement.getEndLine=function(a){return this.getStartLine(a)+this.getNumberOfLines()},Eden.AST.BaseStatement.getRange=function(a){var b=this.getStartLine(a);return[b,b+this.getNumberOfLines()]},Eden.AST.BaseStatement.setSource=function(a,b,c){this.start=a,this.end=b,this.source=c},Eden.AST.BaseStatement.getSource=function(){return this.source},Eden.AST.BaseStatement.getOuterSource=function(){var a=this.getSource();void 0===this.parent&&(a="action "+this.name+"{"+a+"}"),this.doxyComment&&(a="/** "+this.doxyComment.content+" */\n"+a);for(var b=this.parent;b;)"script"==b.type?(a=b.name?"action "+b.name+" {\n"+a+"\n}":"{\n"+a+"\n}",b.doxyComment&&(a="/** "+b.doxyComment.content+" */\n"+a),b=b.parent):b=void 0;return a},Eden.AST.BaseStatement.getOrigin=function(){for(var a=this;a.parent;)a=a.parent;return a.base?a.base.origin:void 0},Eden.AST.BaseScript=function(){Eden.AST.BaseStatement.apply(this),this.statements=[],this.parameters=void 0,this.locals=void 0,this.indexed=!1},Eden.AST.BaseScript.appendChild=function(a){this.statements.push(a),this.statements.length>1&&(a.previousSibling=this.statements[this.statements.length-2],this.statements[this.statements.length-2].nextSibling=a),a.parent=this,this.indexed&&0!=this.id&&console.log("INVALIDATE ID",this),"dummy"!=a.type&&this.indexed&&a.addIndex(),a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.BaseScript.append=Eden.AST.BaseScript.appendChild,Eden.AST.BaseScript.insertAfter=function(a,b){var c;for(c=0;c0&&this.errors.push.apply(this.errors,b.errors),this.indexed&&0!=this.id&&console.log("INVALIDATE ID",this)},Eden.AST.BaseScript.insertBefore=function(a,b){var c;for(c=0;c0&&this.errors.push.apply(this.errors,b.errors),void(this.indexed&&0!=this.id&&console.log("INVALIDATE ID",this))):void eden.emit("error",[new Eden.RuntimeError((void 0),Eden.RuntimeError.NOCHILD,this,"Statement is not a child when using insertBefore")])},Eden.AST.BaseScript.removeChild=function(a){var b;for(b=0;b=this.statements.length)return void eden.emit("error",[new Eden.RuntimeError((void 0),Eden.RuntimeError.NOCHILD,this,"Statement is not a child when using replaceChild")]);c=d}b.nextSibling=this.statements[c].nextSibling,b.nextSibling&&(b.nextSibling.previousSibling=b),b.previousSibling=this.statements[c].previousSibling,b.previousSibling&&(b.previousSibling.nextSibling=b),this.statements[c].destroy(),this.statements[c]=b,b.parent=this,"dummy"!=b.type&&this.indexed&&b.addIndex(),this.indexed&&0!=this.id&&console.log("INVALIDATE ID",this)},Eden.AST.BaseScript.destroy=function(){this.executed<1&&Eden.Index.remove(this);for(var a=0;aa)&&void 0!==this.statements)for(var d=0;d=c&&a<=c+e&&"dummy"!=this.statements[d].type)return this.statements[d];c+=e}},Eden.AST.BaseScript.getRelativeLine=function(a,b){var c=0;b&&b!==this&&this.parent&&(c=this.parent.getRelativeLine(this,b));for(var d=0;d0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Append.prototype.setIndex=function(a){this.index=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Append.prototype.generate=function(a,b){var c=this.index.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type}),d=this.destination.generate(a,b);return this.destination.islocal?d+".push("+c+");\n":b+".mutate("+d+", function(s) { scope.lookup(s.name).value.push("+c+"); }, this);"},Eden.AST.Append.prototype.execute=function(a,b,c,d){this.executed=1;var e=this.index.execute(a,b,c);e instanceof BoundValue&&(e=e.value);var f=eden.root.lookup(this.destination.name),g=f.value(c);g.push(e),f.assign(g,c,this)},Eden.AST.registerStatement(Eden.AST.Append),Eden.AST.Assignment=function(a){this.type="assignment",Eden.AST.BaseContext.apply(this),this.errors=a?a.errors:[],a&&a.warning&&(this.warning=a.warning),this.expression=a,this.lvalue=void 0,this.compiled=void 0,this.dirty=!1,this.value=void 0,this.compiled=void 0},Eden.AST.Assignment.prototype.left=function(a){this.lvalue=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Assignment.prototype.generate=function(a,b){var c=this.lvalue.generate(a,b);return this.lvalue.islocal?(c+=" = ",c+=this.expression.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type}),c+=";\n"):this.lvalue.hasListIndices()?(c=b+".listAssign("+c+",",c+=this.expression.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type}),c+=", Symbol.localJSAgent, false, ",c+=this.lvalue.generateCompList(a,b),c+=");\n"):(c=b+".assign("+c+",",c+=this.expression.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type}),c+=", Symbol.localJSAgent);\n")},Eden.AST.Assignment.prototype.compile=function(ctx){if(!this.compiled||this.dirty){this.dirty=!1,ctx?ctx.scopes=this.scopes:ctx=this;var rhs="(function(context,scope,cache,ctx) { \n",express=this.expression.generate(ctx,"scope",{bound:!0});if(ctx&&ctx.dirty&&(ctx.dirty=!1,this.dirty=!0),this.scopes.length>0){rhs+="\tvar _scopes = [];\n";for(var i=0;i0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.After.prototype.setStatement=function(a){this.statement=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.After.prototype.generate=function(a,b){void 0===b&&(b="eden.root.scope");var c="(function() {"+this.statement.generate(a,b,{bound:!1})+"})",d=this.expression.generate(a,b,{bound:!1});return"setTimeout("+c+", "+d+");\n"},Eden.AST.After.prototype.execute=function(ctx,base,scope){var statement="(function() { var scope = eden.root.scope;\n"+this.statement.generate(ctx,"root.scope")+"})";setTimeout(eval(statement),this.expression.execute(ctx,base,scope))},Eden.AST.registerStatement(Eden.AST.After),Eden.AST.BinaryOp=function(a){this.type="binaryop",this.op=a,this.errors=[],this.l=void 0,this.r=void 0,this.warning=void 0,"&"==this.op||"and"==this.op?this.op="&&":"|"!=this.op&&"or"!=this.op||(this.op="||")},Eden.AST.BinaryOp.prototype.left=Eden.AST.fnEdenASTleft,Eden.AST.BinaryOp.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.BinaryOp.prototype.setRight=function(a){this.r=a,this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.BinaryOp.prototype.generate=function(a,b,c){var d,e={bound:!1,usevar:c.usevar},f=this.l.generate(a,b,e),g=this.r.generate(a,b,e);switch(this.op){case"//":d="concat";break;case"+":d="add";break;case"-":d="subtract";break;case"/":d="divide";break;case"*":d="multiply";break;case"==":d="equal";break;case"%":d="mod";break;case"^":d="pow";break;default:d="RAW"}var h;return h="RAW"!=d?"rt."+d+"(("+f+"),("+g+"))":"("+f+") "+this.op+" ("+g+")",c.bound?"new BoundValue("+h+", "+b+")":h},Eden.AST.BinaryOp.prototype.execute=function(ctx,base,scope){var rhs="(function(context,scope) { return ";return rhs+=this.generate(ctx,"scope",{bound:!1}),rhs+=";})",eval(rhs)(eden.root,scope)},Eden.AST.Break=function(){this.type="break",Eden.AST.BaseStatement.apply(this)},Eden.AST.Break.prototype.generate=function(a,b){return"break; "},Eden.AST.Break.prototype.execute=function(a,b,c,d){var e=new Eden.RuntimeError(b,Eden.RuntimeError.NOTSUPPORTED,this,"Break not supported here");e.line=this.line,this.errors.push(e),Eden.Agent.emit("error",[d,e])},Eden.AST.registerStatement(Eden.AST.Break),Eden.AST.Case=function(){this.type="case",Eden.AST.BaseStatement.apply(this),this.datatype="",this.literal=void 0},Eden.AST.Case.prototype.setLiteral=function(a,b){this.datatype=a,this.literal=b},Eden.AST.Case.prototype.generate=function(a,b){return"string"==typeof this.literal?'case "'+this.literal+'": ':"case "+this.literal+": "},Eden.AST.Case.prototype.execute=function(a,b,c,d){var e=new Eden.RuntimeError(b,Eden.RuntimeError.NOTSUPPORTED,this,"Case not supported here");e.line=this.line,this.errors.push(e),Eden.Agent.emit("error",[d,e])},Eden.AST.registerStatement(Eden.AST.Case),Eden.AST.CodeBlock=function(){this.type="codeblock",Eden.AST.BaseContext.apply(this),this.params=void 0,this.locals=void 0,this.script=void 0},Eden.AST.CodeBlock.prototype.setLocals=function(a){this.locals=a,this.errors.push.apply(this.errors,a.errors)},Eden.AST.CodeBlock.prototype.setParams=function(a){this.params=a,this.errors.push.apply(this.errors,a.errors)},Eden.AST.CodeBlock.prototype.setScript=function(a){this.script=a,a&&(a.parent=this,this.errors.push.apply(this.errors,a.errors))},Eden.AST.CodeBlock.prototype.generate=function(a){var b="(function(context, scope) {\n";if(this.locals&&this.locals.list)for(var c=0;c0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Definition.prototype.generateDef=function(a,b){var c="primary"==this.expression.type&&0==this.expression.extras.length||"scope"==this.expression.type,d="function(context, scope, cache) {\n";this.locals=a?a.locals:void 0,this.params=a?a.params:void 0,this.backtickCount=0;var e=this.expression.generate(this,"scope",{bound:c,indef:!0});if(this.backtickCount>0&&(d+="var btick = 0;\n"),this.scopes.length>0){d+="\tvar _scopes = [];\n";for(var f=0;f0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Delete.prototype.setIndex=function(a){this.index=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Delete.prototype.generate=function(a,b){var c=this.index.generate(a,b,{bound:!1}),d=this.destination.generate(a);return d+".mutate(scope, function(s) { scope.lookup(s.name).value.splice(rt.index("+c+"), 1); }, this);"},Eden.AST.Delete.prototype.execute=function(a,b,c){this.executed=1;var d=this.index.execute(a,b,c);d instanceof BoundValue&&(d=d.value),eden.root.lookup(this.destination.name).mutate(c,function(a){a.value().splice(d-1,1)},this)},Eden.AST.registerStatement(Eden.AST.Delete),Eden.AST.Do=function(){this.type="do",Eden.AST.BaseStatement.apply(this),this.name=void 0,this.script=void 0,this.parameters=[],this.params=[],this.scope=void 0,this.compScope=void 0,this.nscope=void 0,this.selector=void 0},Eden.AST.Do.prototype.addParameter=function(a){this.parameters.push(a),a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Do.prototype.setScript=function(a){this.script=a,this.script&&this.script.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Do.prototype.setName=function(a){a&&a.errors&&this.errors.push.apply(this.errors,a.errors),this.name=a},Eden.AST.Do.prototype.setScope=function(a){this.scope=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Do.prototype.getScope=function(ctx){if(this.scope&&void 0===this.compScope)try{this.compScope=eval("(function (context, scope) { var s = "+this.scope.generateConstructor(ctx,"scope")+"; s.rebuild(); return s; })")}catch(e){}return this.compScope},Eden.AST.Do.prototype.generate=function(a){return""},Eden.AST.Do.prototype.getParameters=function(a,b,c){for(var d=[],e=0;e0){c+='
Parameters:';for(var d=0;d
'+a.slice(1).join(" ")+"
"}c+=""}return c},Eden.AST.DoxyComment.prototype.getParamString=function(){var a=this.getControls()["@param"];if(a&&a.length>0){for(var b="(",c=0;c0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.FunctionCall.prototype.generate=function(a,b){if(void 0===this.lvalue){var c="(";if(this.params)for(var d=0;d0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Index.prototype.generate=function(a,b,c){var d=this.expression.generate(a,b,{bound:!1});return"[rt.index("+d+")]"},Eden.AST.Index.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Insert=function(){this.type="insert",Eden.AST.BaseStatement.apply(this),this.destination=void 0,this.index=void 0,this.value=void 0},Eden.AST.Insert.prototype.setDest=function(a){this.destination=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Insert.prototype.setIndex=function(a){this.index=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Insert.prototype.setValue=function(a){this.value=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Insert.prototype.generate=function(a,b){var c=this.index.generate(a,b,{bound:!1}),d=this.value.generate(a,b,{bound:!1}),e=this.destination.generate(a);return this.destination.islocal?e+".splice(rt.index("+c+"), 0, ("+d+"));":e+".mutate(scope, function(s) { scope.lookup(s.name).value.splice(rt.index("+c+"), 0, ("+d+")); }, this);"},Eden.AST.Insert.prototype.execute=function(a,b,c){this.executed=1;var d=this.index.execute(a,b,c),e=this.value.execute(a,b,c);d instanceof BoundValue&&(d=d.value),e instanceof BoundValue&&(e=e.value),eden.root.lookup(this.destination.name).mutate(c,function(a){a.value().splice(d-1,0,e)},this)},Eden.AST.registerStatement(Eden.AST.Insert),Eden.AST.Length=function(){this.type="length",this.errors=[],this.l=void 0},Eden.AST.Length.prototype.left=Eden.AST.fnEdenASTleft,Eden.AST.Length.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Length.prototype.generate=function(a,b,c){var d=this.l.generate(a,b,{bound:!1,usevar:c.usevar});return c.bound?"new BoundValue(rt.length("+d+"), "+b+")":"rt.length("+d+")"},Eden.AST.Length.prototype.execute=function(a,b,c,d){return rt.length(this.l.execute(a,b,c,d))},Eden.AST.Literal=function(a,b){this.type="literal",Eden.AST.BaseStatement.apply(this),this.datatype=a,this.value=b},Eden.AST.Literal.prototype.generate=function(a,b,c){var d;switch(this.datatype){case"NUMBER":d=this.value;break;case"LIST":d="[";for(var e=0;e0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.LValue.prototype.setExpression=function(a){this.express=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.LValue.prototype.getSymbol=function(a,b,c){if(a&&a.locals&&"declarations"!=a.locals.type&&a.locals.hasOwnProperty(this.name))return this.islocal=!0,a.locals[this.name];if(this.name)return eden.root.lookup(this.name);if(this.primary){var d=this.primary.execute(a,b,c);return d instanceof BoundValue&&(d=d.value),d}if(this.express){var e=this.express.execute(a,b,c);return e instanceof BoundValue&&(e=e.value),eden.root.lookup(e)}},Eden.AST.LValue.prototype.hasListIndices=function(){return this.lvaluep&&this.lvaluep.length>0&&"index"==this.lvaluep[0].kind},Eden.AST.LValue.prototype.generateCompList=function(a,b){for(var c="[",d=0;d0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Modify.prototype.generate=function(a,b){var c=this.lvalue.generate(a),d=c;0==this.lvalue.islocal?d=b+".assign("+c+","+b+".value("+c+")":d+=" = "+c;var e;return this.expression&&(e=this.expression.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type})),"+="==this.kind?d+=" + "+e:"-="==this.kind?d+=" - "+e:"/="==this.kind?d+=" / "+e:"*="==this.kind?d+=" * "+e:"++"==this.kind?d+="+1":"--"==this.kind&&(d+="-1"),d+=0==this.lvalue.islocal?", Symbol.localJSAgent);\n":";\n"},Eden.AST.Modify.prototype.execute=function(ctx,base,scope,agent){var _scopes=[];this.executed=1;var sym=this.lvalue.getSymbol(ctx,base);if("++"==this.kind){var newval=sym.value(scope)+1;sym.assign(newval,scope,this)}else if("--"==this.kind){var newval=sym.value(scope)-1;sym.assign(newval,scope,this)}else{var rhs="(function(context,scope) { return ";rhs+=this.expression.generate(ctx,"scope",{bound:!1}),rhs+=";})";for(var context=eden.root,i=0;i0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Primary.prototype.generate=function(a,b,c){var d;if(a&&a.locals)if("declarations"==a.locals.type){if(a.locals.list.indexOf(this.observable)!=-1){d=this.observable;for(var e=0;e0&&(c+=".observe("+JSON.stringify(this.triggers)+");\n"),c},Eden.AST.Action.prototype.execute=function(ctx,base,scope,agent){this.executed=1,this.doxyComment&&eden.updateDictionary(this.name,this.doxyComment);var body=this.body.generate(ctx),sym=eden.root.lookup(this.name);this.triggers.length>0?sym.define(eval(body),this,[]).observe(this.triggers):sym.define(eval(body),this,[])},Eden.AST.registerStatement(Eden.AST.Action),Eden.AST.Range=function(a){this.type="range",this.parent=void 0,this.errors=a?a.errors:[],this.expression=a,this.lvalue=void 0,this.start=0,this.end=0},Eden.AST.Range.prototype.setSource=function(a,b){this.start=a,this.end=b},Eden.AST.Range.prototype.setSecond=function(a){this.second=a,a&&a.errors&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Range.prototype.left=function(a){this.lvalue=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Range.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Require=function(){this.type="require",Eden.AST.BaseStatement.apply(this),this.expression=void 0},Eden.AST.Require.prototype.setExpression=function(a){this.expression=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Require.prototype.generate=function(a){return"edenUI.loadPlugin("+this.expression.generate(a,"scope",{bound:!1})+");"},Eden.AST.Require.prototype.execute=function(a,b,c){this.executed=1,edenUI.loadPlugin(this.expression.execute(a,b,c))},Eden.AST.registerStatement(Eden.AST.Require),Eden.AST.Return=function(){this.type="return",Eden.AST.BaseStatement.apply(this),this.result=void 0},Eden.AST.Return.prototype.setResult=function(a){this.result=a,this.errors.push.apply(this.errors,a.errors)},Eden.AST.Return.prototype.generate=function(a,b){if(this.result){var c=this.result.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type});return"return "+c+";\n"}return"return;\n"},Eden.AST.Return.prototype.execute=function(a,b,c,d){var e=new Eden.RuntimeError(b,Eden.RuntimeError.NOTSUPPORTED,this,"Return not supported here");e.line=this.line,this.errors.push(e),Eden.Agent.emit("error",[d,e])},Eden.AST.registerStatement(Eden.AST.Return),Eden.AST.Scope=function(){this.type="scope",this.errors=[],this.range=!1,this.overrides={},this.expression=void 0},Eden.AST.Scope.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Scope.prototype.prepend=function(a){this.primary.prepend(a)},Eden.AST.Scope.prototype.setExpression=function(a){this.expression=a,a&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Scope.prototype.addOverride=function(a,b,c,d,e){this.errors.push.apply(this.errors,a.errors),e&&(this.range=!0),d?(this.range=!0,this.overrides[a.observable]={start:b,end:d,increment:c,components:a.components,isin:e},this.errors.push.apply(this.errors,b.errors),this.errors.push.apply(this.errors,c.errors),this.errors.push.apply(this.errors,d.errors)):c?(this.range=!0,this.overrides[a.observable]={start:b,end:c,components:a.components,isin:e},this.errors.push.apply(this.errors,b.errors),this.errors.push.apply(this.errors,c.errors)):b&&(this.overrides[a.observable]={start:b,end:void 0,components:a.components,isin:e},this.errors.push.apply(this.errors,b.errors))},Eden.AST.Scope.prototype.generateConstructor=function(a,b){var c;c="new Scope(context, "+b+", [";for(var d in this.overrides){var e,f=this.overrides[d];if(e=this.range?f.start.generate(a,b,{bound:!1}):f.start.generate(a,b,{bound:"primary"==f.start.type||"scope"==f.start.type}),c+='new ScopeOverride("'+d+'", '+e,f.end){var g=this.overrides[d].end.generate(a,b,{bound:!1});if(f.increment){var h=f.increment.generate(a,b,{bound:!1});c+=", "+g+", "+h+"),"}else c+=", "+g+"),"}else c+=", undefined, undefined, "+f.isin+"),"}return c=c.slice(0,-1),c+="], "+this.range+", this,true)"; -},Eden.AST.Scope.prototype.generate=function(a,b,c){if(a.scopes.push(this.generateConstructor(a,b)),this.range){var d="_scopes["+(a.scopes.length-1)+"]",e=this.expression.generate(a,"_scopes["+(a.scopes.length-1)+"].clone()",c),f="(function() {\n";return f+=d+".range = false;\n",f+="var results = [];\n",f+="var scoperesults = [];\n",f+="while(true) {\n",f+="var val = "+e,c.bound&&(f+=";\n\tif (val.value !== undefined) scoperesults.push(val.scope);\n\tval = val.value"),f+=";\n",f+="if (val !== undefined) results.push(val);\n",f+="if ("+d+".next() == false) break;\n",f+="}\n"+d+".range = true;\n",f+=c.bound?"if (cache) cache.scopes = scoperesults;\n return new BoundValue(results,"+d+");}).call(this)":"return results;}).call(this)"}return this.expression.generate(a,"_scopes["+(a.scopes.length-1)+"]",c)},Eden.AST.Scope.prototype.execute=function(ctx,base,scope){var context={scopes:[]},gen=this.generate(context,"scope",{bound:!1}),rhs="(function(context,scope) {\n";if(context.scopes.length>0){rhs+="\tvar _scopes = [];\n";for(var i=0;i0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.ScopePath.prototype.generate=function(a,b,c){var d=this.path.generate(a,b,{bound:!0,scopeonly:!0});return this.primary.generate(a,d,c)},Eden.AST.ScopePath.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.ScopePattern=function(){this.type="scopepattern",this.observable="NONAME",this.components=[],this.errors=[]},Eden.AST.ScopePattern.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.ScopePattern.prototype.setObservable=function(a){this.observable=a},Eden.AST.ScopePattern.prototype.addListIndex=function(a){this.components.push(a),a&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Script=function(){this.type="script",Eden.AST.BaseScript.apply(this),this.name=void 0,this.active=!1,this.base=void 0,this.prefix="",this.postfix=""},Eden.AST.registerScript(Eden.AST.Script),Eden.AST.Script.prototype.getActionByName=function(a){for(var b,c=0;c0?(a.replaceChild(d,c[e.id][0]),c[e.id].shift(),0==c[e.id].length&&delete c[e.id]):"dummy"!=e.type&&this.indexed&&e.addIndex()}for(var f in c)for(var g=c[f],d=0;d0){void 0===a.locals&&(a.locals={});for(var f=0;f0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.ScriptExpr.prototype.generate=function(a,b){for(var c="(function(escope) {\nescope.isolate = true;\nif (cache) cache.scope = escope;\nvar context = new Eden.AST.Context(context);\nescope.context = context;\n",d=0;d0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Subscribers.prototype.execute=function(a,b,c){},Eden.AST.Subscribers.prototype.setList=function(a){this.list=a},Eden.AST.registerStatement(Eden.AST.Subscribers),Eden.AST.Switch=function(){this.type="switch",Eden.AST.BaseStatement.apply(this),this.expression="",this.statement=void 0,this.compiled=void 0},Eden.AST.Switch.prototype.setExpression=function(a){this.expression=a,a&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Switch.prototype.setStatement=function(a){this.statement=a,this.errors.push.apply(this.errors,a.errors)},Eden.AST.Switch.prototype.generate=function(a,b){void 0===b&&(b="eden.root.scope");var c="switch(";return c+=this.expression.generate(a,b,{bound:!1}),c+=") "+this.statement.generate(a,b)},Eden.AST.Switch.prototype.getSelector=function(ctx){if(this.compiled)return this.compiled;var cond="(function(context,scope) { return ";return cond+=this.expression.generate(ctx,"scope",{bound:!1}),cond+=";})",this.compiled=eval(cond),this.compiled},Eden.AST.Switch.prototype.execute=function(a,b,c,d){var e=new Eden.RuntimeError(b,Eden.RuntimeError.NOTSUPPORTED,this,"Switch not supported here");e.line=this.line,this.errors.push(e),Eden.Agent.emit("error",[d,e])},Eden.AST.registerStatement(Eden.AST.Switch),Eden.AST.TernaryOp=function(a){this.type="ternaryop",this.op=a,this.errors=[],this.first=void 0,this.second=void 0,this.condition=void 0,this.warning=void 0},Eden.AST.TernaryOp.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.TernaryOp.prototype.setFirst=function(a){this.first=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.TernaryOp.prototype.setSecond=function(a){this.second=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.TernaryOp.prototype.setCondition=function(a){this.condition=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.TernaryOp.prototype.left=function(a){void 0===this.condition?this.condition=a:this.first=a,a&&a.warning&&(this.warning=a.warning)},Eden.AST.TernaryOp.prototype.generate=function(a,b,c){var d=this.condition.generate(a,b,{bound:!1,usevar:c.usevar}),e=this.first.generate(a,b,c),f=this.second.generate(a,b,c);return"(("+d+")?("+e+"):("+f+"))"},Eden.AST.TernaryOp.prototype.execute=function(ctx,base,scope){var rhs="(function(context,scope) { return ";return rhs+=this.generate(ctx,"scope",{bound:!1}),rhs+=";})",eval(rhs)(eden.root,scope)},Eden.AST.UnaryOp=function(a,b){this.type="unaryop",this.op=a,this.errors=b.errors,this.r=b},Eden.AST.UnaryOp.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.UnaryOp.prototype.generate=function(a,b,c){var d,e=this.r.generate(a,b,{bound:!1,usevar:c.usevar});return"!"==this.op?d="!("+e+")":"&"==this.op?(d="context.lookup("+e+")",console.log(d)):"-"==this.op?d="-("+e+")":"*"==this.op&&(d=e+".value("+b+")"),c.bound?"new BoundValue("+d+","+b+")":d},Eden.AST.UnaryOp.prototype.execute=function(ctx,base,scope){var rhs="(function(context,scope) { return ";return rhs+=this.generate(ctx,"scope",{bound:!1}),rhs+=";})",eval(rhs)(eden.root,scope)},Eden.AST.Wait=function(){this.type="wait",Eden.AST.BaseStatement.apply(this),this.delay=void 0,this.compiled_delay=void 0},Eden.AST.Wait.prototype.setDelay=function(a){this.delay=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Wait.prototype.compile=function(ctx){if(void 0!==this.delay&&!this.compiled_delay){var source="(function(context,scope) { return ";source+=this.delay.generate(ctx,"scope",{bound:!1}),source+=";})",this.compiled_delay=eval(source)}},Eden.AST.Wait.prototype.generate=function(a,b){return"yield "+this.delay+";"},Eden.AST.registerStatement(Eden.AST.Wait),Eden.AST.When=function(){this.type="when",Eden.AST.BaseContext.apply(this),this.name="*When",this.id=0,this.expression=void 0,this.active=!1,this.compiled=void 0,this.scope=void 0,this.compScope=void 0,this.local=!1,this.dirty=!1,this.statement=void 0,this.enabled=!1,this.statements=[]},Eden.AST.registerContext(Eden.AST.When),Eden.AST.When.prototype.addTrigger=function(a,b,c){var d=a.triggers[b];if(d){for(var e=0;e0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Query.prototype.setResultTypes=function(a){this.restypes=a},Eden.AST.Query.prototype.setModify=function(a,b){this.modexpr=a,this.kind=b,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Query.prototype.generate=function(a,b,c){var d="Eden.Selectors.query("+this.selector.generate(a,b,{bound:!1})+', "'+this.restypes.join(",")+'")';return console.log("QUERY",d),c.bound?"new BoundValue("+d+","+b+")":d},Eden.AST.Query.prototype.execute=function(a,b,c,d){if(this.executed=1,void 0===this.modexpr){var e=Eden.Selectors.query(this.selector.execute(a,b,c,d),this.restypes);b.lastresult=e}else{var f=this.selector.execute(a,b,c,d),g=this.modexpr.execute(a,b,c,d);switch(this.kind){case"=":Eden.Selectors.assign(f,this.restypes,g);break;case"+=":Eden.Selectors.append(f,this.restypes,g);break;case"//=":Eden.Selectors.concat(f,this.restypes,g)}}},Eden.AST.registerStatement(Eden.AST.Query),Eden.AST.Alias=function(){this.type="script",Eden.AST.BaseStatement.apply(this),this.name=void 0,this.active=!1,this.selector=void 0},Eden.AST.Alias.prototype.setName=function(a){this.name=a},Eden.AST.Alias.prototype.setSelector=function(a){this.selector=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Alias.prototype.execute=function(a,b,c,d){return Eden.Selectors.query(this.selector.execute(a,b,c,d))},Eden.AST.Alias.prototype.generate=function(a,b,c){},Eden.AST.registerStatement(Eden.AST.Alias),Object.defineProperty(Eden.AST.Alias.prototype,"statements",{get:function(){if(this.selector){var a=this.selector.execute(this,eden.project.ast,eden.root.scope,this);return Eden.Selectors.query(a)}return[]}}),Eden.AST.Alias.addIndex=function(){this.buildID(),Eden.Index.update(this)},Eden.AST.Alias.removeIndex=function(){Eden.Index.remove(this)},Eden.AST.Alias.destroy=function(){this.executed<1&&Eden.Index.remove(this),this.parent=void 0,this.executed=-1},Eden.AST.Indexed=function(){this.type="indexed",this.indexes=[],this.expression=void 0,this.errors=[]},Eden.AST.Indexed.prototype.left=Eden.AST.fnEdenASTleft,Eden.AST.Indexed.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Indexed.prototype.setExpression=function(a){this.expression=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Indexed.prototype.addIndex=function(a){this.indexes.push(a),a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Indexed.prototype.generate=function(a,b,c){for(var d="",e=0;ethis.depth);)"dummy"!=f.type&&"script"!=f.type&&"section"!=f.type&&e.push(f),f=f.nextSibling;return e},Eden.AST.registerStatement(Eden.AST.Section),Eden.AST.Section.prototype.getRange=function(a){for(var b=this.getStartLine(a),c=this.nextSibling;c&&c.nextSibling&&("section"!=c.nextSibling.type||c.nextSibling.depth>this.depth);)c=c.nextSibling;c&&"dummy"==c.type&&(c=c.previousSibling);var d=c?c.getEndLine(a):b+this.getNumberOfLines();return[b,d]},Eden.AST.prototype.pACTIONBODY=function(){var a=new Eden.AST.CodeBlock,b=this.parent;return this.parent=a,"{"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONOPEN)),this.parent=b,a):(this.next(),a.setLocals(this.pLOCALS()),a.locals.errors.length>0?(this.parent=b,a):(a.setScript(this.pSCRIPT()),"}"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),this.parent=b,a):(this.next(),this.parent=b,a)))},Eden.AST.prototype.pAFTER=function(){var a=new Eden.AST.After;if("("!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.AFTEROPEN)),a;this.next();var b=this.pEXPRESSION();if(a.setExpression(b),a.errors.length>0)return a;if(")"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.AFTEROPEN)),a;this.next();var c=this.pSTATEMENT();return void 0===c&&a.error(new Eden.SyntaxError(this,Eden.SyntaxError.AFTERNOSTATEMENT)),a.setStatement(c),a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.DEPRECATED,"'after' should not be used, use 'wait' instead"),a},Eden.AST.prototype.pPARAMS=function(){var a=new Eden.AST.Declarations;for(a.kind="oracle";"para"==this.token||"oracle"==this.token;){this.next();var b=this.pOLIST();if(a.list.push.apply(a.list,b),0==b.length||"NONAME"==b[b.length-1])return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.PARAMNAME)),a;if(";"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.PARAMSEMICOLON)),a;this.next()}return a},Eden.AST.prototype.pLOCALS=function(){for(var a=new Eden.AST.Declarations;"auto"==this.token||"local"==this.token;){this.next();var b=this.pOLIST();if(a.list.push.apply(a.list,b),0==b.length||"NONAME"==b[b.length-1])return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LOCALNAME)),a;if(";"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LOCALSEMICOLON)),a;this.next()}return a},Eden.AST.prototype.pDO=function(){var a=new Eden.AST.Do,b=this.parent;if(this.parent=a,"{"==this.token){this.next();var c=this.pSCRIPT();return c.parent=a,"}"!=this.token?(a.setScript(c),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),this.parent=b,a):(this.next(),a.setScript(c),this.parent=b,"with"!=this.token&&"::"!=this.token||(this.next(),a.setScope(this.pSCOPE())),a)}if("OBSERVABLE"!=this.token&&"."!=this.token&&">>"!=this.token&&">"!=this.token&&"<"!=this.token&&"<<"!=this.token&&":"!=this.token&&"*"!=this.token&&"@"!=this.token&&"#"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.DONAME)),this.parent=b,a;var d=this.pCODESELECTOR();if(a.setName(d),a.errors.length>0)return this.parent=b,a;if("with"==this.token||"::"==this.token)this.next(),a.setScope(this.pSCOPE());else if(";"!=this.token)for(var e=this.pELIST(),f=0;f0)return this.parent=b,a;return";"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),this.parent=b,a):(this.next(),this.parent=b,a)},Eden.AST.prototype.pEXPRESSION_PPPPP=function(){if("#"==this.token)return this.next(),new Eden.AST.Length},Eden.AST.prototype.pEXPRESSION_PPPPPP=function(){if("?"==this.token){this.next();var a=new Eden.AST.TernaryOp("?");return a.setFirst(this.pEXPRESSION()),a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.DEPRECATED,"use of ? for 'if'."),a.errors.length>0?a:":"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.TERNIFCOLON)),a):(this.next(),a.setSecond(this.pEXPRESSION()),a)}if("if"==this.token){this.next();var a=new Eden.AST.TernaryOp("?");return a.setCondition(this.pEXPRESSION()),a.errors.length>0?a:"else"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.TERNIFCOLON)),a):(this.next(),a.setSecond(this.pEXPRESSION()),a)}},Eden.AST.prototype.pEXPRESSION_PLAIN=function(){for(var a=this.pTERM();"&&"==this.token||"||"==this.token||"&"==this.token||"|"==this.token||"and"==this.token||"or"==this.token;){var b=new Eden.AST.BinaryOp(this.token);this.next(),b.left(a),b.setRight(this.pTERM()),a=b}return a},Eden.AST.prototype.pEXPRESSION=function(){var a;if("{"==this.token){if(this.next(),a=this.pSCRIPTEXPR(),"}"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),a;this.next()}else a=this.pEXPRESSION_PLAIN();if("with"==this.token||"::"==this.token){this.next();var b=this.pSCOPE();return b.setExpression(a),b}return a},Eden.AST.prototype.pFACTOR=function(){if("("==this.token){this.next();var a=this.pEXPRESSION();if(a.errors.length>0)return a;if(")"!=this.token?a.error(new Eden.SyntaxError(this,Eden.SyntaxError.EXPCLOSEBRACKET)):this.next(),"["==this.token){var b=this.pINDEXED();return b.setExpression(a),b}return a}if("$"==this.token){this.next();var c=0;if("#"==this.token)c=-1;else if("NUMBER"!=this.token||this.data.value<1){var d=new Eden.AST.Parameter((-1));return d.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.PARAMNUMBER)),d}return c=this.data.value,this.next(),new Eden.AST.Parameter(c)}if("["==this.token){this.next();var e=[];"]"!=this.token&&(e=this.pELIST());for(var f=new Eden.AST.Literal("LIST",e),g=0;g0&&f.errors.push.apply(f.errors,e[g].errors);return f.errors.length>0?f:("]"!=this.token?f.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTLITCLOSE)):this.next(),f)}if("@"==this.token)return this.next(),new Eden.AST.Literal("UNDEFINED","@");if("JAVASCRIPT"==this.token){var h=new Eden.AST.Literal("JAVASCRIPT",this.data.value);return this.next(),h}if("NUMBER"==this.token){var h=new Eden.AST.Literal("NUMBER",this.data.value);return this.next(),h}if("?"==this.token){this.next();var i=this.pQUERY();if("["==this.token){var b=this.pINDEXED();return b.setExpression(i),b}return i}if("-"==this.token){this.next();var j=new Eden.AST.UnaryOp("-",this.pFACTOR());return j}if("<<"==this.token){if(this.next(),"OBSERVABLE"!=this.token){var h=new Eden.AST.Literal("STRING",this.data.value);return h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.HEREDOCTOKEN)),h}var k=this.data.value;if(10!=this.stream.get()){var h=new Eden.AST.Literal("STRING",this.data.value);return h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.HEREDOCTOKEN)),h}for(var l="";this.stream.valid();){var m=this.stream.position,n=this.stream.readLine();if(n.startsWith(k)){this.stream.position=m+3;break}l+=n}this.stream.valid()||this.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.NEWLINE)),this.next();var h=new Eden.AST.Literal("STRING",l.slice(0,-1).replace(/\\/g,"\\\\").replace(/"/g,'\\"'));return h}if("STRING"==this.token){var h=new Eden.AST.Literal("STRING",this.data.value);for(this.data.error||this.next();0==this.data.error&&"STRING"==this.token;)h.value+="\n"+this.data.value,this.next();return this.data.error&&("LINEBREAK"==this.data.value?h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LITSTRLINE)):h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LITSTRCLOSE))),h}if("BOOLEAN"==this.token){var h=new Eden.AST.Literal("BOOLEAN",this.data.value);return this.next(),h}if("CHARACTER"==this.token){var h=new Eden.AST.Literal("CHARACTER",this.data.value);return this.data.error?(""==this.data.value?h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LITCHAREMPTY)):h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LITCHARCLOSE)),h):(this.next(),h)}if("!"==this.token||"not"==this.token){this.next();var o=this.pFACTOR();return new Eden.AST.UnaryOp("!",o)}if("&"==this.token){this.next();var p=this.pLVALUE();return new Eden.AST.UnaryOp("&",p)}if("*"==this.token){this.next();var p=this.pFACTOR();return new Eden.AST.UnaryOp("*",p)}var q=this.pPRIMARY();return q},Eden.AST.prototype.pFOR=function(){var a=new Eden.AST.For,b=this.parent;if(this.parent=a,"("!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FOROPEN)),this.parent=b,a;if(this.next(),";"==this.token)this.next();else{if(a.setStart(this.pSTATEMENT_P(!0)),a.errors.length>0)return this.parent=b,a;if("range"!=a.sstart.type&&";"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FORSTART)),this.parent=b,a;";"==this.token&&this.next()}if("range"!=a.sstart.type){if(";"==this.token)this.next();else{if(a.setCondition(this.pEXPRESSION()),a.errors.length>0)return this.parent=b,a;if(";"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FORCOND)),this.parent=b,a;this.next()}if(")"==this.token)this.next();else{if(a.setIncrement(this.pSTATEMENT_P()),a.errors.length>0)return this.parent=b,a;if(")"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FORCLOSE)),this.parent=b,a;this.next()}}else{if(")"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FORCLOSE)),this.parent=b,a;this.next()}return a.setStatement(this.pSTATEMENT()),a.statement&&(a.statement.parent=a),a.parent=b,this.parent=b,a},Eden.AST.prototype.pFUNCTION=function(){var a=new Eden.AST.Function,b=this.parent;return this.parent=a,"OBSERVABLE"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCNAME)),this.parent=b,a):(a.name=this.data.value,this.next(),a.setBody(this.pFUNCBODY()),this.parent=b,a)},Eden.AST.prototype.pFUNCBODY=function(){var a=new Eden.AST.CodeBlock,b=this.parent;return this.parent=a,"{"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCOPEN)),this.parent=b,a):(this.next(),a.setParams(this.pPARAMS()),a.params.errors.length>0?(this.parent=b,a):(a.setLocals(this.pLOCALS()),a.locals.errors.length>0?(this.parent=b,a):(a.setScript(this.pSCRIPT()),"}"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCLOSE)),this.parent=b,a):(this.next(),this.parent=b,a))))},Eden.AST.prototype.pIF=function(){var a=new Eden.AST.If;a.parent=this.parent;var b=this.parent;return this.parent=a,"("!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.IFCONDOPEN)),this.parent=b,a):(this.next(),a.setCondition(this.pEXPRESSION()),a.errors.length>0?(this.parent=b,a):")"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.IFCONDCLOSE)),this.parent=b,a):(this.next(),a.setStatement(this.pSTATEMENT()),a.errors.length>0?(this.parent=b,a):void 0===a.statement?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.IFNOSTATEMENT)),this.parent=b,a):(a.setElse(this.pIF_P()),this.parent=b,a)))},Eden.AST.prototype.pIF_P=function(){if("else"==this.token)return this.next(),this.pSTATEMENT()},Eden.AST.prototype.pREQUIRE=function(){var a=new Eden.AST.Require,b=this.pEXPRESSION();return a.setExpression(b),a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.DEPRECATED,"require."),";"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a)},Eden.AST.prototype.pIMPORT=function(){var a=new Eden.AST.Import,b=this.pCODESELECTOR();return void 0===b||b.errors.length>0?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.IMPORTPATH)),a):(a.setPath(b),";"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a))},Eden.AST.prototype.pINSERT=function(){var a=new Eden.AST.Insert;return a.setDest(this.pLVALUE()),a.errors.length>0?a:","!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.INSERTCOMMA)),a):(this.next(),a.setIndex(this.pEXPRESSION()),a.errors.length>0?a:","!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.INSERTCOMMA)),a):(this.next(),a.setValue(this.pEXPRESSION()),a.errors.length>0?a:";"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a)))},Eden.AST.prototype.pDELETE=function(){var a=new Eden.AST.Delete;return a.setDest(this.pLVALUE()),a.errors.length>0?a:","!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.DELETECOMMA)),a):(this.next(),a.setIndex(this.pEXPRESSION()),a.errors.length>0?a:";"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a))},Eden.AST.prototype.pAPPEND=function(){var a=new Eden.AST.Append;return a.setDest(this.pLVALUE()),a.errors.length>0?a:","!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.APPENDCOMMA)),a):(this.next(),a.setIndex(this.pEXPRESSION()),a.errors.length>0?a:";"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a))},Eden.AST.prototype.pSHIFT=function(){var a=new Eden.AST.Shift;return a.setDest(this.pLVALUE()),a.errors.length>0?a:";"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a)},Eden.AST.prototype.pELIST=function(){ -var a=this.pEXPRESSION();if(a.errors.length>0)return[a];var b=this.pELIST_P();return b.unshift(a),b},Eden.AST.prototype.pELIST_P=function(){for(var a=[];","==this.token;){this.next();var b=this.pEXPRESSION();if(a.push(b),b.errors.length>0)return a}return a},Eden.AST.prototype.pOLIST=function(){if("OBSERVABLE"!=this.token)return[];var a=this.data.value;this.next();var b=this.pOLIST_P();return b.unshift(a),b},Eden.AST.prototype.pOLIST_P=function(){for(var a=[];","==this.token;){if(this.next(),"OBSERVABLE"!=this.token)return a.push("NONAME"),a;a.push(this.data.value),this.next()}return a},Eden.AST.prototype.pLVALUE_P=function(){for(var a=[];;){if("["!=this.token)break;this.next();var b=new Eden.AST.LValueComponent("index"),c=this.pEXPRESSION();if(b.index(c),a.push(b),c.errors.length>0&&b.errors.unshift(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP)),"literal"==b.indexexp.type&&"NUMBER"==b.indexexp.datatype&&b.indexexp.value<1&&b.error(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS)),"]"!=this.token)return b.error(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE)),a;this.next()}return a},Eden.AST.prototype.pLVALUE=function(){var a=new Eden.AST.LValue;if("*"==this.token)this.next(),a.setPrimary(this.pPRIMARY());else if("`"==this.token){if(this.next(),a.setExpression(this.pEXPRESSION()),a.errors.length>0)return a;if("`"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.BACKTICK)),a;this.next()}else{if("OBSERVABLE"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.LVALUE)),a;var b=this.data.value;if(this.next(),"{"==this.token){for(var c=new Eden.AST.Literal("STRING",b);"{"==this.token;){this.next();var d=this.pEXPRESSION();if(d.errors.length>0)return a.setExpression(d),a;if("}"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.BACKTICK)),a;this.next();var e=new Eden.AST.BinaryOp("//");if(e.left(c),e.setRight(d),c=e,"OBSERVABLE"==this.token){var e=new Eden.AST.BinaryOp("//");e.left(c),e.setRight(new Eden.AST.Literal("STRING",this.data.value)),c=e,this.next()}}a.setExpression(c)}else a.setObservable(b)}return a.setExtras(this.pLVALUE_P()),a},Eden.AST.prototype.pPRIMARY=function(){if("`"==this.token){this.next();var a=this.pEXPRESSION();if(a.errors.length>0){var b=new Eden.AST.Primary;return b.setBackticks(a),b}if("`"!=this.token){var b=new Eden.AST.Primary;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.BACKTICK)),b}this.next();var b=this.pPRIMARY_P();return b.errors.length>0?b:(b.setBackticks(a),b.setObservable("__BACKTICKS__"),b)}if("OBSERVABLE"==this.token){var b,c=this.data.value;if(this.next(),"{"==this.token){for(var d=new Eden.AST.Literal("STRING",c);"{"==this.token;){this.next();var a=this.pEXPRESSION();if(a.errors.length>0){var b=new Eden.AST.Primary;return b.setBackticks(a),b}if("}"!=this.token){var b=new Eden.AST.Primary;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.BACKTICK)),b}this.next();var e=new Eden.AST.BinaryOp("//");if(e.left(d),e.setRight(a),d=e,"OBSERVABLE"==this.token){var e=new Eden.AST.BinaryOp("//");e.left(d),e.setRight(new Eden.AST.Literal("STRING",this.data.value)),d=e,this.next()}}b=this.pPRIMARY_P(),b.setBackticks(d),b.setObservable("__BACKTICKS__")}else b=this.pPRIMARY_P(),b.setObservable(c);return b}var b=new Eden.AST.Primary;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.BADFACTOR)),b},Eden.AST.prototype.pPRIMARY_P=function(){if("["==this.token){this.next();var a=new Eden.AST.Index;if("]"==this.token){var b=new Eden.AST.Primary;return b.prepend(a),b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP)),b}var c=this.pEXPRESSION();if(c.errors.length>0){a.setExpression(c);var b=new Eden.AST.Primary;return b.prepend(a),b}if("literal"==c.type&&"NUMBER"==c.datatype&&c.value<1){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS));var b=new Eden.AST.Primary;return b.prepend(a),b}if("]"!=this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE));var b=new Eden.AST.Primary;return b.prepend(a),b}this.next();var b=this.pPRIMARY_PPP();return a.setExpression(c),b.prepend(a),b}if("("==this.token){this.next();var d=new Eden.AST.FunctionCall;if(")"==this.token){this.next();var b=this.pPRIMARY_PP();return b.prepend(d),b}var e=this.pELIST();if(d.setParams(e),d.errors.length>0){var b=new Eden.AST.Primary;return b.prepend(d),b}if(")"!=this.token){var b=new Eden.AST.Primary;return b.prepend(d),d.errors.length>0?b:(b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCALLEND)),b)}this.next();var b=this.pPRIMARY_PP();return b.errors.length>0?b:(b.prepend(d),b)}if("."==this.token){this.next();var f=this.pPRIMARY(),g=new Eden.AST.ScopePath;return g.setPrimary(f),g}return this.pPRIMARY_PPPP()},Eden.AST.prototype.pPRIMARY_PP=function(){if("["==this.token){this.next();var a=new Eden.AST.Index;if("]"==this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP));var b=new Eden.AST.Primary;return b.prepend(a),b}var c=this.pEXPRESSION();if(c.errors.length>0){var b=new Eden.AST.Primary;return a.setExpression(c),b.prepend(a),b}if("literal"==c.type&&"NUMBER"==c.datatype&&c.value<1){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS));var b=new Eden.AST.Primary;return b.prepend(a),b}if("]"!=this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE));var b=new Eden.AST.Primary;return b.prepend(a),b}this.next();var b=this.pPRIMARY_PP();return a.setExpression(c),b.prepend(a),b}if("("==this.token){this.next();var d=new Eden.AST.FunctionCall;if(")"==this.token){this.next();var b=this.pPRIMARY_PP();return b.prepend(d),b}var e=this.pELIST();if(d.setParams(e),")"!=this.token){var b=new Eden.AST.Primary;return b.prepend(d),d.errors.length>0?b:(b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCALLEND)),b)}this.next();var b=this.pPRIMARY_PP();return b.prepend(d),b}return this.pPRIMARY_PPPP()},Eden.AST.prototype.pPRIMARY_PPP=function(){if("["==this.token){this.next();var a=new Eden.AST.Index;if("]"==this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP));var b=new Eden.AST.Primary;return b.prepend(a),b}var c=this.pEXPRESSION();if(c.errors.length>0){var b=new Eden.AST.Primary;return a.setExpression(c),b.prepend(a),b}if("literal"==c.type&&"NUMBER"==c.datatype&&c.value<1){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS));var b=new Eden.AST.Primary;return b.prepend(a),b}if("]"!=this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE));var b=new Eden.AST.Primary;return b.prepend(a),b}this.next();var b=this.pPRIMARY_PP();return a.setExpression(c),b.prepend(a),b}if("("==this.token){this.next();var d=new Eden.AST.FunctionCall;if(")"==this.token){this.next();var b=this.pPRIMARY_PP();return b.prepend(d),b}var e=this.pELIST();if(d.setParams(e),")"!=this.token){var b=new Eden.AST.Primary;return b.prepend(d),d.errors.length>0?b:(b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCALLEND)),b)}this.next();var b=this.pPRIMARY_PP();return b.errors.length>0?b:(b.prepend(d),b)}if("."==this.token){this.next();var f=this.pPRIMARY();if(f.errors.length>0)return f;var g=new Eden.AST.ScopePath;return g.setPrimary(f),g}return this.pPRIMARY_PPPP()},Eden.AST.prototype.pPRIMARY_PPPP=function(){return new Eden.AST.Primary},Eden.AST.prototype.pACTION=function(){var a=new Eden.AST.Action,b=this.parent;if(this.parent=a,a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.DEPRECATED,"attempt to use 'when' instead of 'proc'"),"OBSERVABLE"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.PROCNAME)),this.parent=b,a;if(a.name=this.data.value,this.next(),":"==this.token){this.next();var c=this.pOLIST();if(0==c.length)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONNOWATCH)),this.parent=b,a;if("NONAME"==c[c.length-1])return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCOMMAS)),this.parent=b,a;a.triggers=c}return a.setBody(this.pFUNCBODY()),this.parent=b,a},Eden.AST.prototype.pSCOPE=function(){if("("==this.token){this.next();var a=this.pSCOPE_P();return")"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SCOPECLOSE)),a):(this.next(),a)}return this.pSCOPE_P()},Eden.AST.prototype.pSCOPEPATTERN=function(){var a=new Eden.AST.ScopePattern;if("OBSERVABLE"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SCOPENAME)),a;for(a.setObservable(this.data.value),this.next();;)if("["==this.token){this.next();var b=this.pEXPRESSION();if(a.addListIndex(b),b.errors.length>0)return a;if("]"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE)),a;this.next()}else if("."!=this.token)break;return a},Eden.AST.prototype.pSCOPE_P=function(){var a=this.pSCOPEPATTERN(),b=!1;if(a.errors.length>0){var c=new Eden.AST.Scope;return c.addOverride(a,void 0,void 0,void 0,!1),c}if("is"!=this.token&&"="!=this.token&&"in"!=this.token){var c=new Eden.AST.Scope;return c.error(new Eden.SyntaxError(this,Eden.SyntaxError.SCOPEEQUALS)),c}"in"==this.token&&(b=!0),this.next();var d=this.pEXPRESSION();if(d.errors.length>0){var c=new Eden.AST.Scope;return c.errors.push.apply(c.errors,d.errors),c}var e=void 0;if(".."==this.token&&(this.next(),e=this.pEXPRESSION(),e.errors.length>0)){var c=new Eden.AST.Scope;return c.addOverride(a,d,e,void 0,!1),c}var f=void 0;if(".."==this.token&&(this.next(),f=this.pEXPRESSION(),f.errors.length>0)){var c=new Eden.AST.Scope;return c.addOverride(a,d,e,f,!1),c}var c=this.pSCOPE_PP();return c.addOverride(a,d,e,f,b),c},Eden.AST.prototype.pSCOPE_PP=function(){return","==this.token?(this.next(),this.pSCOPE_P()):new Eden.AST.Scope},Eden.AST.prototype.pNAMEDSCRIPT=function(){var a;if("OBSERVABLE"!=this.token){var b=new Eden.AST.Script;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONNAME)),b}if(a=this.data.value,this.next(),"is"==this.token){this.next();var c=new Eden.AST.Alias;return c.setSelector(this.pCODESELECTOR()),c.setName(a),";"!=this.token?(c.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),c):(this.next(),c)}if("{"!=this.token){var b=new Eden.AST.Script;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONOPEN)),b}this.next();var b=this.pSCRIPT();return b.errors.length>0?b:(b.setName(this,a),"}"!=this.token?(b.error(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),b):(this.next(),this.scripts[a]=b,b))},Eden.AST.prototype.pSCRIPT=function(){var a=new Eden.AST.Script;a.parent=this.parent;var b=this.parent;this.parent=a;var c=new Eden.AST.DummyStatement;for(c.setSource(this.lastposition,this.stream.prevposition,this.stream.code.substring(this.lastposition,this.stream.prevposition)),c.numlines=c.source.match(/\n/g),null===c.numlines?c.numlines=0:c.numlines=c.numlines.length,a.append(c);"EOF"!=this.token;){var d=this.pSTATEMENT();if(void 0!==d){if(d.errors.length>0){a.appendChild(d);break}var e=d.end;a.appendChild(d);var f=this.stream.code.substring(e,this.stream.prevposition);if(f.length>0){var c=new Eden.AST.DummyStatement;c.setSource(e,this.stream.prevposition,f),c.numlines=c.source.match(/\n/g),null===c.numlines?c.numlines=0:c.numlines=c.numlines.length,a.appendChild(c)}}else{if("}"!=this.token&&";"!=this.token&&a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.STATEMENT)),";"!=this.token)break;this.next()}}return this.parent=b,a},Eden.AST.prototype.pSCRIPTEXPR=function(){var a=new Eden.AST.ScriptExpr;a.parent=this.parent;for(this.parent;"EOF"!=this.token;){var b=this.pSTATEXPR();if(void 0!==b){if(a.append(b),b.errors.length>0)break}else{if("}"!=this.token&&";"!=this.token&&a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.STATEMENT)),";"!=this.token)break;this.next()}}return a},Eden.AST.prototype.pAGENTPATH=function(){if("OBSERVABLE"!=this.token&&void 0===Language.keywords[this.token])return"_ERROR_";var a=this.data.value;for(this.next();"/"==this.token;){if(this.next(),"OBSERVABLE"!=this.token&&void 0===Language.keywords[this.token])return"_ERROR_";a+="/"+this.data.value,this.next()}return a},Eden.AST.prototype.pCODESELECTOR=function(){var a=void 0;if("OBSERVABLE"==this.token||Language.keywords[this.token])a=new Eden.AST.Literal("STRING",this.data.value),this.next();else if(":"==this.token||"."==this.token){var b=":"==this.token;if(this.next(),"OBSERVABLE"==this.token){if(!(!b&&Eden.Selectors.PropertyNode.attributes[this.data.value]||b&&Eden.Selectors.PropertyNode.pseudo[this.data.value]))return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTORATTRIB)),a;a=new Eden.AST.Literal("STRING",(b?":":".")+this.data.value),this.next()}else if("NUMBER"==this.token)a=new Eden.AST.Literal("STRING",(b?":":".")+this.data.value),this.next();else if("{"==this.token)a=new Eden.AST.Literal("STRING",b?":":".");else{if("("!=this.token)return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTORATTRIB)),a;var c=this.stream.position;for(this.next();this.stream.valid()&&")"!=this.token;)this.next();var d=this.stream.prevposition,e=":("+this.stream.code.substring(c,d).replace(/[\r\n]*/g,"")+")";a=new Eden.AST.Literal("STRING",e),this.next()}}else if("@"==this.token){if(this.next(),"OBSERVABLE"!=this.token)return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTOROPTION)),a;if(!Eden.Selectors.allowedOptions[this.data.value])return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTOROPTION)),a;a=new Eden.AST.Literal("STRING","@"+this.data.value+" "),this.next()}else if("#"==this.token)if(this.next(),"OBSERVABLE"==this.token)a=new Eden.AST.Literal("STRING","#"+this.data.value),this.next();else{if("{"!=this.token)return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTORTAG)),a;a=new Eden.AST.Literal("STRING","#")}else if("{"==this.token){if(this.next(),a=this.pEXPRESSION(),"}"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTORBTICK)),a;this.next()}else if(">"==this.token)a=new Eden.AST.Literal("STRING"," > "),this.next();else if(">>"==this.token)a=new Eden.AST.Literal("STRING"," >> "),this.next();else if("<"==this.token)a=new Eden.AST.Literal("STRING"," < "),this.next();else if(","==this.token)a=new Eden.AST.Literal("STRING",","),this.next();else if("<<"==this.token)a=new Eden.AST.Literal("STRING"," << "),this.next();else if("("==this.token){var c=this.stream.position;for(this.next();this.stream.valid()&&")"!=this.token;)this.next();var d=this.stream.prevposition,e="("+this.stream.code.substring(c,d).replace(/[\r\n]*/g,"")+")";a=new Eden.AST.Literal("STRING",e),this.next()}else{if(")"==this.token)return;"*"==this.token&&(a=new Eden.AST.Literal("STRING","*"),this.next())}if(a){var f=this.pCODESELECTOR();if(void 0===f)return a;if(f.errors.length>0)return f;if("literal"==a.type&&"literal"==f.type)a.value+=f.value;else{var g=new Eden.AST.BinaryOp("//");g.left(a),g.setRight(f),a=g}}return a},Eden.AST.prototype.pSTATEMENT_PP=function(a){if("is"==this.token){this.next();var b=new Eden.AST.Definition,c=this.parent;this.parent=b;var d=this.pEXPRESSION();return b.setExpression(d),this.parent=c,b}if("in"==this.token){if(this.next(),!a){var e=new Eden.AST.Range;return e.error(new Eden.SyntaxError(this,Eden.SyntaxError.RANGEBANNED)),e}var e=new Eden.AST.Range(this.pEXPRESSION());return".."==this.token&&(this.next(),e.setSecond(this.pEXPRESSION())),e}if("="==this.token)return this.next(),new Eden.AST.Assignment(this.pEXPRESSION());if("+="==this.token)return this.next(),new Eden.AST.Modify("+=",this.pEXPRESSION());if("-="==this.token)return this.next(),new Eden.AST.Modify("-=",this.pEXPRESSION());if("/="==this.token)return this.next(),new Eden.AST.Modify("/=",this.pEXPRESSION());if("*="==this.token)return this.next(),new Eden.AST.Modify("*=",this.pEXPRESSION());if("~>"==this.token){this.next();var f=new Eden.AST.Subscribers;return"["!=this.token?(f.error(new Eden.SyntaxError(this,Eden.SyntaxError.SUBSCRIBEOPEN)),f):(this.next(),f.setList(this.pOLIST()),f.errors.length>0?f:"]"!=this.token?(f.error(new Eden.SyntaxError(this,Eden.SyntaxError.SUBSCRIBECLOSE)),f):(this.next(),f))}if("++"==this.token)return this.next(),new Eden.AST.Modify("++",(void 0));if("--"==this.token)return this.next(),new Eden.AST.Modify("--",(void 0));if("("==this.token){var g=new Eden.AST.FunctionCall;if(this.next(),")"!=this.token){if(g.setParams(this.pELIST()),g.errors.length>0)return g;if(")"!=this.token)return g.error(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCLOSE)),g}return this.next(),g}var h=[];h.push(new Eden.SyntaxError(this,Eden.SyntaxError.DEFINITION));var i=new Eden.AST.Assignment((void 0));return i.errors.unshift(h[0]),i},Eden.AST.prototype.pSTATEMENT_P=function(a){var b=this.pLVALUE();if(b.errors.length>0)return b;var c=this.pSTATEMENT_PP(a);return c.left(b),c.errors.length>0?c:c},Eden.AST.prototype.pSTATEMENT=function(){var a=this.stream.prevposition,b=this.stream.line-1,c=-1,d=void 0,e=-1,f=this.lastDoxyComment.length>0?this.lastDoxyComment.pop():void 0;switch(0==this.lastDoxyComment.length&&this.parentDoxy&&this.lastDoxyComment.push(this.parentDoxy),this.token){case"proc":this.next(),d=this.pACTION();break;case"func":this.next(),d=this.pFUNCTION();break;case"when":this.next(),d=this.pWHEN();break;case"action":this.next(),d=this.pNAMEDSCRIPT();break;case"for":this.next(),d=this.pFOR();break;case"while":this.next(),d=this.pWHILE();break;case"do":this.next(),d=this.pDO();break;case"wait":this.next(),d=this.pWAIT();break;case"switch":this.next(),d=this.pSWITCH();break;case"case":this.next(),d=this.pCASE();break;case"insert":this.next(),d=this.pINSERT();break;case"delete":this.next(),d=this.pDELETE();break;case"append":this.next(),d=this.pAPPEND();break;case"shift":this.next(),d=this.pSHIFT();break;case"require":this.next(),d=this.pREQUIRE();break;case"after":this.next(),d=this.pAFTER();break;case"import":this.next(),d=this.pIMPORT();break;case"local":case"auto":d=this.pLOCALS();break;case"default":this.next();var g=new Eden.AST.Default;":"!=this.token?g.error(new Eden.SyntaxError(this,Eden.SyntaxError.DEFAULTCOLON)):this.next(),d=g;break;case"if":this.next(),d=this.pIF();break;case"#":var h=this.stream.position+1,i=this.stream.line,j=33==this.stream.peek();do this.stream.skipLine(),this.stream.valid()||this.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.NEWLINE)),this.stream.skip(),this.stream.line++;while(35==this.stream.peek()&&35!=this.stream.peek2());if(j){var k=new Eden.AST.DoxyComment(this.stream.code.substring(h,this.stream.position-1).trim(),i,this.stream.line);k.parent=this.parentDoxy,k.content.endsWith("@{")?this.parentDoxy=k:k.content.startsWith("@}")&&this.parentDoxy&&(this.parentDoxy=this.parentDoxy.parent),!this.lastStatement||void 0!==this.lastStatement.doxyComment||this.lastStatEndline!=i-1&&this.lastStatEndline!=i?this.lastDoxyComment.push(k):this.lastStatement.setDoxyComment(k)}this.next(),d=new Eden.AST.DummyStatement;break;case"##":d=this.pSECTION(),this.lastDoxyComment.length>0&&this.lastline==this.lastDoxyComment[0].startline-1&&d.setDoxyComment(this.lastDoxyComment.shift());break;case"return":this.next();var l=new Eden.AST.Return;if(";"==this.token){this.next(),d=l;break}if(l.setResult(this.pEXPRESSION()),l.errors.length>0){d=l;break}";"!=this.token?l.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),d=l;break;case"continue":this.next();var m=new Eden.AST.Continue;if(m.errors.length>0){d=m;break}";"!=this.token?m.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),d=m;break;case"break":this.next();var n=new Eden.AST.Break;if(n.errors.length>0){d=n;break}";"!=this.token?n.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),d=n;break;case"{":this.next();var o=this.pSCRIPT();if("}"!=this.token){o.error(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),d=o;break}this.next(),d=o;break;case"JAVASCRIPT":b=this.data.line-1;var p=this.data.value;this.next(),d=new Eden.AST.Literal("JAVASCRIPT",p);break;case"?":this.next(),d=this.pQUERY(),";"!=this.token?d.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next();break;case"`":case"*":case"OBSERVABLE":var q=this.pLVALUE();if(q.errors.length>0){d=new Eden.AST.DummyStatement,d.lvalue=q,d.errors=q.errors;break}var r=this.pSTATEMENT_PP();if(r.left(q),r.errors.length>0){d=r;break}";"!=this.token?r.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),void 0===this.definitions[q.name]&&(this.definitions[q.name]=[]),this.definitions[q.name].push(r),d=r;break;default:return}return e=this.lastposition,c=this.lastline,d.parent=this.parent,void 0===d.doxyComment&&d.setDoxyComment(f),d.stamp=this.stamp,d.numlines=c-b-1,d.setSource(a,e,this.stream.code.substring(a,e)),"dummy"!=d.type&&(this.lastStatement=d,this.lastStatEndline=c),d},Eden.AST.prototype.pSTATEXPR=function(){var a=(this.stream.prevposition,void 0),b=this.lastDoxyComment;switch(this.lastDoxyComment=this.parentDoxy,this.token){case"proc":case"func":case"when":case"wait":case"do":case"require":case"after":case"import":case"action":a=new Eden.AST.DummyStatement,a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.UNKNOWN));break;case"for":this.next(),a=this.pFOR();break;case"while":this.next(),a=this.pWHILE();break;case"switch":this.next(),a=this.pSWITCH();break;case"case":this.next(),a=this.pCASE();break;case"insert":this.next(),a=this.pINSERT();break;case"delete":this.next(),a=this.pDELETE();break;case"append":this.next(),a=this.pAPPEND();break;case"shift":this.next(),a=this.pSHIFT();break;case"para":case"oracle":a=this.pPARAMS();break;case"local":case"auto":a=this.pLOCALS();break;case"default":this.next();var c=new Eden.AST.Default;":"!=this.token?c.error(new Eden.SyntaxError(this,Eden.SyntaxError.DEFAULTCOLON)):this.next(),a=c;break;case"if":this.next(),a=this.pIF();break;case"return":this.next();var d=new Eden.AST.Return;if(";"==this.token){this.next(),a=d;break}if(d.setResult(this.pEXPRESSION()),d.errors.length>0){a=d;break}";"!=this.token?d.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),a=d;break;case"continue":this.next();var e=new Eden.AST.Continue;if(e.errors.length>0){a=e;break}";"!=this.token?e.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),a=e;break;case"break":this.next();var f=new Eden.AST.Break;if(f.errors.length>0){a=f;break}";"!=this.token?f.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),a=f;break;case"{":this.next();var g=this.pSCRIPT();if("}"!=this.token){g.error(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),endline=this.stream.line,a=g;break}endline=this.stream.line,this.next(),a=g;break;case"JAVASCRIPT":curline=this.data.line-1;var h=this.data.value;this.next(),a=new Eden.AST.Literal("JAVASCRIPT",h);break;case"`":case"*":case"OBSERVABLE":var i=this.pLVALUE();if(i.errors.length>0){a=new Eden.AST.DummyStatement,a.lvalue=i,a.errors=i.errors;break}var j=this.pSTATEMENT_PP();if(j.left(i),j.errors.length>0){a=j,endline=this.stream.line;break}";"!=this.token?j.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):(end=this.stream.position,endline=this.stream.line,this.next()),void 0===this.definitions[i.name]&&(this.definitions[i.name]=[]),this.definitions[i.name].push(j),a=j;break;default:return}return a.parent=this.parent,a.doxyComment=b,a},Eden.AST.prototype.pSWITCH=function(){var a=new Eden.AST.Switch,b=this.parent;return this.parent=a,"("!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SWITCHOPEN)),this.parent=b,a):(this.next(),a.setExpression(this.pEXPRESSION()),a.errors.length>0?(this.parent=b,a):")"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SWITCHCLOSE)),this.parent=b,a):(this.next(),"{"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SWITCHSCRIPT)),this.parent=b,a):(a.setStatement(this.pSTATEMENT()),this.parent=b,a)))},Eden.AST.prototype.pCASE=function(){var a=new Eden.AST.Case;return"STRING"!=this.token&&"NUMBER"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.CASELITERAL)),a):(a.setLiteral(this.token,this.data.value),this.next(),":"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.CASECOLON)),a):(this.next(),a))},Eden.AST.prototype.pTERM=function(){var a=this.pTERM_A(),b=this.pEXPRESSION_PPPPPP();return b?(b.left(a),b):a},Eden.AST.prototype.pTERM_A=function(){for(var a=this.pTERM_P();"<"==this.token||"<="==this.token||">"==this.token||">="==this.token||"=="==this.token||"!="==this.token;){var b=new Eden.AST.BinaryOp(this.token);this.next(),b.left(a),b.setRight(this.pTERM_P()),a=b}return a},Eden.AST.prototype.pTERM_P=function(){for(var a=this.pTERM_PP();"+"==this.token||"-"==this.token||"//"==this.token;){var b=new Eden.AST.BinaryOp(this.token);this.next(),b.left(a),b.setRight(this.pTERM_PP()),a=b}return a},Eden.AST.prototype.pTERM_PP=function(){for(var a=this.pTERM_PPP();"*"==this.token||"/"==this.token||"%"==this.token||"^"==this.token;){var b=new Eden.AST.BinaryOp(this.token);this.next(),b.left(a),b.setRight(this.pTERM_PPP()),a=b}return a},Eden.AST.prototype.pTERM_PPP=function(){var a=this.pFACTOR(),b=this.pEXPRESSION_PPPPP();return b?(b.left(a),b):a},Eden.AST.prototype.pWAIT=function(){var a=new Eden.AST.Wait;if(";"==this.token)return this.next(),a;var b=this.pEXPRESSION();return a.setDelay(b),";"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a)},Eden.AST.prototype.pWHEN=function(){var a=new Eden.AST.When,b=this.parent;if(this.parent=a,"("!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.WHENOPEN)),this.parent=b,a;if(this.next(),a.setExpression(this.pEXPRESSION()),a.errors.length>0)return this.parent=b,a;if(")"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.WHENCLOSE)),this.parent=b,a;if(this.next(),a.setStatement(this.pSTATEMENT()),a.errors.length>0)return this.parent=b,a;if(void 0===a.statement)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.WHENNOSTATEMENT)),a.active=!0,this.parent=b,a;if("with"==this.token||"::"==this.token){this.next();var c=this.pSCOPE();if(a.setScope(c),c.errors.length>0)return a;if(";"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a;this.next()}return a.compile(this),this.whens.push(a),this.parent=b,a},Eden.AST.prototype.pWHILE=function(){var a=new Eden.AST.While,b=this.parent;return this.parent=a,a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.USEOFWHILE),"("!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.WHILEOPEN)),this.parent=b,a):(this.next(),a.setCondition(this.pEXPRESSION()),a.errors.length>0?(this.parent=b,a):")"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.WHILECLOSE)),this.parent=b,a):(this.next(),a.setStatement(this.pSTATEMENT()),void 0===a.statement?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.WHILENOSTATEMENT)),this.parent=b,a):(this.parent=b,a)))},Eden.AST.prototype.pQUERY=function(){var a=new Eden.AST.Query,b=[];if("("!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYOPEN)),a;if(this.next(),a.setSelector(this.pCODESELECTOR()),")"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYCLOSE)),a;if(this.next(),"["!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYSELECTOPEN)),a;for(this.next();this.stream.valid()&&"]"!=this.token&&(b.push(this.data.value),this.next(),"]"!=this.token);){if(","!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYSELECTCOMMA)),a;this.next()}if("]"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYSELECTCLOSE)),a;if(this.next(),"="==this.token||"+="==this.token||"//="==this.token){var c=this.token;this.next();var d=this.pEXPRESSION();a.setModify(d,c)}return 0==b.length&&b.push("id"),a.setResultTypes(b),a},Eden.AST.prototype.pINDEXED=function(){for(var a=new Eden.AST.Indexed;this.stream.valid()&&"["==this.token;){this.next();var b=new Eden.AST.Index;if("]"==this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP)),a;var c=this.pEXPRESSION();if(c.errors.length>0)return b.setExpression(c),a.addIndex(b),a;if("literal"==c.type&&"NUMBER"==c.datatype&&c.value<1)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS)),a;if("]"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE)),a;this.next(),b.setExpression(c),a.addIndex(b)}return a},Eden.AST.prototype.pSECTION=function(){for(var a=1;35==this.stream.peek();)a++,this.stream.skip();var b=this.stream.readLine().trim();return this.stream.valid()?(this.stream.position--,this.stream.line--):this.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.NEWLINE)),this.next(),stat=new Eden.AST.Section,stat.setName(b),stat.depth=a,stat},Eden.Project=function(a,b,c){this.title=b,this.name=b.replace(/[^a-zA-Z0-9]/g,""),this.author=void 0,this.authorid=-1,this.tags=b.toLowerCase().split(" "),this.src=c,this.ast=new Eden.AST(c,(void 0),this),this.id=a,this.vid=void 0,this.parentid=void 0,this.triggers={},this.thumb=void 0,this.desc=void 0,this.readPassword=void 0,this.ast&&0==this.ast.script.errors.length,eden.root.lookup("jseden_project_title").assign(b,eden.root.scope,Symbol.localJSAgent),eden.root.lookup("jseden_project_name").assign(this.name,eden.root.scope,Symbol.localJSAgent)},Eden.Project.listenTo=listenTo,Eden.Project.emit=emit,Eden.Project.unListen=unListen,Eden.Project.listeners={},Eden.Project.init=function(){var a=eden.root.lookup("jseden_project_title");a.addJSObserver("project",function(a,b){if(a.origin!==eden.project){if(void 0===eden.project)return;eden.project.title=b,void 0===this.id&&(Eden.Index.remove(eden.project.ast.script),eden.project.name=b.replace(/[^a-zA-Z0-9]/g,""),eden.project.ast.script.name=eden.project.name,console.log("REINDEX PROJECT"),Eden.Index.update(eden.project.ast.script)),eden.project.ast.script.doxyComment=eden.project.ast.doxyFromOrigin(),Eden.Fragment.emit("aststatus",[eden.project.ast.script])}}),$.get("resources/projects.db.json",function(a){Eden.Project.local=a},"json"),eden.root.addGlobal(function(a,b){if(void 0!==eden.project){var c=eden.project.triggers[a.name];if(c)for(var d=0;d'+h+"",null!==g&&(e+=g.length)}else if(2==c[f][1]){var h=EdenUI.Highlight.html(c[f][1]);d+="line:"+(e+1)+' - '+h+"",null!==g&&(e-=g.length)}}else null!==g&&(e+=g.length)}return d},Eden.Project.prototype.save=function(a,b){Eden.DB.save(this,a,b)},Eden.Project.restore=function(){if(window.localStorage){var a=window.localStorage.getItem("last_project"),b=window.localStorage.getItem("last_id");"undefined"==b&&(b=void 0);var c=window.localStorage.getItem("last_vid");"undefined"==c&&(c=void 0);var d=window.localStorage.getItem("last_author");"undefined"==d&&(d=void 0);var e=window.localStorage.getItem("last_authorid"),f=window.localStorage.getItem("last_name"),g=window.localStorage.getItem("last_thumb");"undefined"==g&&(g=void 0);var h=window.localStorage.getItem("last_desc"),i=window.localStorage.getItem("last_title");a&&""!=a&&(eden.root.lookup("jseden_project_mode").assign("restore",eden.root.scope,Symbol.defaultAgent),eden.project=new Eden.Project(b,i,a),eden.project.vid=c,eden.project.author=d,eden.project.name=f,eden.project.authorid=e,eden.project.thumb=g,eden.project.desc=h,eden.project.start())}},Eden.Project.prototype.restore=function(){},Eden.Project.prototype.localSave=function(){window.localStorage&&(window.localStorage.setItem("last_project",this.generate()),window.localStorage.setItem("last_id",this.id),window.localStorage.setItem("last_vid",this.vid),window.localStorage.setItem("last_author",this.author),window.localStorage.setItem("last_authorid",this.authorid),window.localStorage.setItem("last_name",this.name),window.localStorage.setItem("last_title",this.title),window.localStorage.setItem("last_thumb",this.thumb),window.localStorage.setItem("last_desc",this.desc))},Eden.Project.prototype.patch=function(a,b){},Eden.Project.prototype.snapshot=function(){},Eden.Project.prototype.addAction=function(a){var b=Eden.AST.parseStatement("action "+a+" {}");return this.ast.script.appendChild(b),b.addIndex(),b},Eden.Project.prototype.generate=function(){return this.ast.getSource()},Eden.Project.prototype.getDescription=function(){return void 0===this.desc&&(this.desc="# "+this.title+"\nEnter a project description here,\nand some hashtags as below.\n\nTags: #"+this.tags.join(" #")),this.desc},Eden.Project.prototype.setDescription=function(a){this.desc=a;var b=new Eden.AST.DoxyComment(a,0,0);this.tags=b.getHashTags().map(function(a){return a.substring(1)})},Eden.Project.prototype.addTrigger=function(a,b,c){console.log("Add When Trigger",b),void 0===this.triggers[b]&&(this.triggers[b]=[]),this.triggers[b].push({statement:a,scope:c})},Eden.Project.prototype.registerAgent=function(a){console.log("REGISTER WHEN",a);for(var b in a.dependencies)void 0===this.triggers[b]&&(this.triggers[b]=[]),this.triggers[b].push({statement:a,scope:eden.root.scope})},Eden.Project.prototype.removeAgent=function(a){console.log("REMOVE WHEN",a);for(var b in a.dependencies){var c=this.triggers[b];if(c)for(var d=0;d1){for(var d="",e=0;e0||b.remote;var g=b.originast.doxyComment;if(g){b.doxy=g;var h=g.getControls();h["@title"]&&(b.title=h["@title"][0])}else b.doxy=void 0;Eden.Fragment.emit("changed",[b]),b.locked&&Eden.Fragment.emit("locked",[b])}else console.log("Make scratch fragment"),b.locked=!1,b.remote=!1,b.ast=new Eden.AST(b.source,(void 0),b,{noindex:!0}),b.originast=b.ast.script,b.name="*Scratch*",b.title=b.name,b.scratch=!0,Eden.Fragment.emit("changed",[b]);b.lock(),b.snapshot=b.source,a&&a()})},Eden.Fragment.prototype.getSource=function(){return this.source?this.source:""},Eden.Fragment.prototype.makeReal=function(a){if(this.scratch){this.name=a,this.title=a,this.originast=eden.project.addAction(a),this.selector=Eden.Selectors.getID(this.originast),this.scratch=!1,this.remote=!1,this.setSource(this.source);for(var b=this.originast;b&&b.parent;)b=b.parent;this.origin=b.base.origin,this.lock()}},Eden.Fragment.prototype.setSourceInitial=function(a){this.source=a,this.snapshot=a,this.ast=new Eden.AST(a,(void 0),this)},Eden.Fragment.AUTOSAVE_INTERVAL=500,Eden.Fragment.prototype.undo=function(){if(!(this.index<0)&&0!=this.history.length){var a=this.history[this.index];this.index--;var b;if(this.index>=0&&this.history[this.index].snapshot)b=this.history[this.index].snapshot;else{var c=new diff_match_patch,d=c.patch_fromText(a.undo),e=c.patch_apply(d,this.snapshot);b=e[0]}this.snapshot=b,this.setSource(b)}},Eden.Fragment.prototype.canUndo=function(){return this.history.length>0&&this.index>=0},Eden.Fragment.prototype.canRedo=function(){return this.index=this.history.length-1)){this.index++;var a,b=this.history[this.index];if(b.snapshot)a=b.snapshot;else{var c=new diff_match_patch,d=c.patch_fromText(b.redo),e=c.patch_apply(d,this.snapshot);a=e[0]}this.snapshot=a,this.setSource(a)}},Eden.Fragment.prototype.addHistory=function(a,b){this.history.push({time:Date.now()/1e3|0,redo:a,undo:b}),this.index=this.history.length-1},Eden.Fragment.prototype.autoSave=function(){if(!(void 0===this.ast||this.ast.script.errors.length>0)){if(this.originast){var a=this.originast.parent;for(this.originast.patchScript(this.ast);a;)Eden.Fragment.emit("patch",[this,a]),a=a.parent}Eden.Fragment.emit("changed",[this])}},Eden.Fragment.prototype.diff=function(){if(this.origin&&this.origin.ast&&this.originast.end>0){var a=this.origin.ast.stream.code.substring(this.originast.start,this.originast.end),b=this.originast.prefix.length,c=this.originast.postfix.length;return a=a.substring(b,a.length-c),DiffUtil.diff(a,this.source)}},Eden.Fragment.prototype.setSource=function(a){if(!this.locked){var b=this;if(this.source=a,this.edited=!0,this.ast=new Eden.AST(a,(void 0),this,{noindex:!0}),0==this.ast.errors.length){if(this.originast){var c=this.originast.parent;for(this.originast.patchInner(this.ast.script),Eden.Fragment.emit("patch",[this,this.originast]);c;)Eden.Fragment.emit("patch",[this,c]),c=c.parent}Eden.Fragment.emit("status",[this]),eden.root.lookup("jseden_fragment_changed").assign(b.selector,eden.root.scope,Symbol.localJSAgent)}else Eden.Fragment.emit("errored",[this])}},Eden.Fragment.prototype.lock=function(){if(this.originast)for(var a=this.originast.parent;a;)a.lock++,Eden.Fragment.emit("lock",[this,a]),a=a.parent},Eden.Fragment.prototype.unlock=function(){if(this.originast)for(var a=this.originast.parent;a;)a.lock--,0==a.lock&&Eden.Fragment.emit("unlock",[this,a]),a=a.parent},Eden.Fragment.prototype.getTitle=function(){return this.originast&&this.originast.name?this.originast.name:this.name},Eden.Query={},Eden.Query.sortByCount=sortByCount,Eden.Query.reduceByCount=reduceByCount,Eden.Query.negativeFilter=negativeFilter,Eden.Query.search=function(a,b){var c=a.split(/[ ]+/),d=!1,e=0,f=c.length,g=!0,h=!0,i=!1,j=!0,k=!0,l=!0,m=!0,n={views:[],symbols:[],whens:[],projects:[],scripts:[],statements:[]};if(c.length>0&&":"==c[0].charAt(c[0].length-1)){if(e=1,d=!0,"select:"==c[0]){var o=a.substring(c[0].length).trim();return n.all=Eden.Selectors.query(o,"source"),void 0===n.all&&(n.all=[]),b&&b(n),b&&o.length>=3&&(Eden.Query.dbseltimeout&&clearTimeout(Eden.Query.dbseltimeout),Eden.Query.dbseltimeout=setTimeout(function(){Eden.Query.dbseltimeout=void 0,Eden.DB.searchSelector(o,"source",function(a){n.all.push.apply(n.all,a),b(n)})},1e3)),n}switch(c[0]){case"procs:":case"whens:":case"agents:":h=!0,g=!1,i=!1,j=!1,doremovescripts=!1,l=!0,m=!1;break;case"scripts:":h=!1,g=!1,j=!0,k=!0,i=!1,l=!1,m=!1}}for(f-=e;e2?!function(a){Eden.Query.dbtimeout&&clearTimeout(Eden.Query.dbtimeout),Eden.Query.dbtimeout=setTimeout(function(){Eden.Query.dbtimeout=void 0,Eden.DB.search(a,function(a){n.scripts.push.apply(n.scripts,a),n.scripts=reduceByCount(n.scripts,f),n.scripts=sortByLoaded(n.scripts),Eden.Query.mergeResults(n),b&&b(n)})},500)}(c[e]):j&&n.scripts.push.apply(n.scripts,Eden.Query.searchScripts(q))}else f--;return n.symbols=reduceByCount(n.symbols,f),Eden.Query.mergeResults(n),b&&b(n),n},Eden.Query.mergeResults=function(a){function b(d,e){c=0;for(var f=e;f=d);f++)c++,a.all.push("/"+a.symbols[f]);c=0;for(var f=e;f=d);f++)c++,a.all.push(a.whens[f]);c=0;for(var f=e;f=d-1);f++)c++,a.all.push("*script"+a.scripts[f]);c=0;for(var f=e;f=d);f++)c++,a.all.push(a.statements[f]);(a.symbols.length>e+d||a.whens.length>e+d||a.scripts.length>e+d)&&b(2,e+d)}a.all=[];var c=0;b(3,0)},Eden.Query.searchViews=function(a){},Eden.Query.searchSymbols=function(a,b){var c=[];for(var d in eden.root.symbols){var e=eden.root.symbols[d];if(a.test(d))e.last_modified_by.internal||"_"==d.charAt(0)||c.push(d);else if(b&&eden.dictionary[d]){var f=eden.dictionary[d].getHashTags();if(f)for(var g=0;g').html("").dialog({title:"Peer Connections",width:200,height:300,minHeight:120,minWidth:100})}this.connections={},this.id=id,this.master=master;var me=this;this.roles={},this.enabled=!1,this.loading=!1,this.config={control:!0,share:!1,observe:!1,logging:!1},this.callbacks={},this.callbackid=0,this.capturepatch=!1,void 0===eden.root.lookup("jseden_p2p_newconnections").value()&&eden.root.lookup("jseden_p2p_newconnections").assign([],eden.root.scope,Symbol.defaultAgent),void 0===eden.root.lookup("jseden_p2p_newdisconnections").value()&&eden.root.lookup("jseden_p2p_newdisconnections").assign([],eden.root.scope,Symbol.defaultAgent),void 0===eden.root.lookup("jseden_p2p_errors").value()&&eden.root.lookup("jseden_p2p_errors").assign([],eden.root.scope,Symbol.defaultAgent),Eden.Selectors.execute("lib > p2p"),Eden.DB.listenTo("login",this,init),Eden.DB.isLoggedIn()&&init(Eden.DB.username);var capInSym=eden.root.lookup("jseden_p2p_captureinput");capInSym.addJSObserver("p2p",function(a,b){b?(Symbol.hciAgent.local=!1,Symbol.localJSAgent.local=!1):(Symbol.hciAgent.local=!0,Symbol.localJSAgent.local=!0)});var capEdSym=eden.root.lookup("jseden_p2p_captureedits");capEdSym.addJSObserver("p2p",function(a,b){me.capturepatch=b}),edenUI.views.Peers={dialog:createDialog,title:"Connections",category:edenUI.viewCategories.environment},edenUI.menu.updateViewsMenu()},Eden.Peer.listeners={},Eden.Peer.emit=emit,Eden.Peer.listenTo=listenTo,Eden.Peer.prototype.broadcast=function(a){if(!this.loading){a=JSON.stringify(a);for(var b in this.connections){var c=this.connections[b];c.share&&c.connection.send(a)}}},Eden.Peer.prototype.broadcastExcept=function(a,b){if(!this.loading){b=JSON.stringify(b);for(var c in this.connections)if(c!=a){var d=this.connections[c];d.share&&d.connection.send(b)}}},Eden.Peer.prototype.authoriseWhen=function(a){if(this.enabled){if(a.doxyComment){var b=a.doxyComment.getControls()["@role"];if(b){for(var c=0;c0&&a>0&&10!=this.context.stream.code.charCodeAt(b);)b--,a--;return 10==this.context.stream.code.charCodeAt(b)&&b++,this.context.stream.code.substr(b,this.prevposition-b)},Eden.SyntaxError.prototype.extractToken=function(){return this.context.stream.code.substr(this.prevposition,this.position-this.prevposition)},Eden.SyntaxError.prototype.extractAfter=function(a){for(var b=this.position;b0&&10!=this.context.stream.code.charCodeAt(b);)b++,a--;return this.context.stream.code.substr(this.position,b-this.position)},Eden.SyntaxError.prototype.buildSuggestion=function(){var a=Eden.SyntaxError.db[this.errno].suggestion;return a.next.indexOf(this.token)!=-1?this.extractBefore(10)+a.expected[0]+" "+this.extractToken()+this.extractAfter(10):this.extractBefore(10)+a.expected[0]+" "+this.extractAfter(10)},Eden.SyntaxError.prototype.messageText=function(){var a=Eden.SyntaxError.db[this.errno],b=Language.errors[this.errno][a.message.call(this)];return void 0===this.extra?b:b+": "+this.extra},Eden.SyntaxError.prototype.prettyPrint=function(){this.context.stream.pushPosition(),this.context.stream.move(this.position);var a=Eden.SyntaxError.db[this.errno],b=Language.errors[this.errno][a.message.call(this)],c="Error:\n "+b+"\n Source : "+this.context.src+", line "+this.line+"\n Code : "+this.errno;return c+="\n Here : "+this.extractBefore(10)+">>> "+this.extractToken()+" <<<"+this.extractAfter(10),a.suggestion&&(c+="\n Suggestion : "+this.buildSuggestion()),this.context.stream.popPosition(),c},Eden.SyntaxError.prototype.toString=function(){return this.prettyPrint()},Eden.RuntimeError=function(a,b,c,d){this.type="runtime",this.line=-1,this.statement=c,this.extra=d,this.errno=b,this.context=a,this.lastsymbol=eden.root.lastlookup,console.error(d)},Eden.RuntimeError.UNKNOWN=0,Eden.RuntimeError.ASSIGNEXEC=1,Eden.RuntimeError.FUNCCALL=2,Eden.RuntimeError.ACTIONNAME=3,Eden.RuntimeError.NOAGENT=4,Eden.RuntimeError.NOTSUPPORTED=5,Eden.RuntimeError.ASSIGNTODEFINED=6,Eden.RuntimeError.ASSIGNDIMENSION=7,Eden.RuntimeError.EXTENDSTATIC=8,Eden.RuntimeError.INFINITERANGE=9,Eden.RuntimeError.NOLISTRANGE=10,Eden.RuntimeError.LEFTCONCAT=11,Eden.RuntimeError.RIGHTCONCAT=12,Eden.RuntimeError.AGENTSOURCE=13,Eden.RuntimeError.JSOBSERVER=14,Eden.RuntimeError.PROCAGENT=15,Eden.RuntimeError.ARGUMENTS=16,Eden.RuntimeError.NOTCHILD=17,Eden.RuntimeError.prototype.messageText=function(){var a=!this.statement||"functioncall"!=this.statement.type&&"definition"!=this.statement.type&&"assignment"!=this.statement.type?"":"'"+this.statement.lvalue.name+"': ";switch(this.errno){case Eden.RuntimeError.ACTIONNAME:case Eden.RuntimeError.NOAGENT:case Eden.RuntimeError.NOTSUPPORTED:case Eden.RuntimeError.AGENTSOURCE:case Eden.RuntimeError.JSOBSERVER:case Eden.RuntimeError.PROCAGENT:case Eden.RuntimeError.ARGUMENTS:case Eden.RuntimeError.EXTENDSTATIC:return a+this.extra;case Eden.RuntimeError.ASSIGNTODEFINED:return a+"cannot assign to a defined list, use 'is'";case Eden.RuntimeError.ASSIGNDIMENSION:return a+"list does not have this many dimensions";case Eden.RuntimeError.RIGHTCONCAT:return a+"Concatenation: When the right hand side is a list then the left hand side must also be a list";case Eden.RuntimeError.LEFTCONCAT:return a+"Concatenation: When the left hand side is a list then the right hand side must also be a list";case Eden.RuntimeError.INFINITERANGE:return a+"range scope is infinite";case Eden.RuntimeError.NOLISTRANGE:return a+"range 'in' is not a list"}return String(this.extra).search("is not a function")>=0?a+"function used does not exist":this.errno==Eden.RuntimeError.FUNCCALL&&String(this.extra).search("Cannot read property 'call'")>=0?a+"procedure does not exist":String(this.extra).match(/Cannot read property .* of undefined/)?a+"uses an undefined list":this.extra},Eden.RuntimeError.prototype.edenSource=function(){if(this.statement)if("definition"==this.statement.type){var a=eden.root.symbols[this.statement.lvalue.name];if(a&&a.definition)return a.getSource()}else if(this.context)return this.context.getSource(this.statement)},Eden.RuntimeError.prototype.javascriptSource=function(){return this.statement.generate({scopes:[],dependencies:{}},"scope")},Eden.RuntimeError.prototype.details=function(){var a="";return"definition"!=this.statement.type&&"assignment"!=this.statement.type||(a+="Symbol: "+this.statement.lvalue.name+"\n"),a+=String(this.extra).search("SyntaxError")>=0?"JavaScript: "+this.javascriptSource()+"\n":"Source: "+this.edenSource()+"\n",this.extra.message&&(a+="Original: "+this.extra.message+"\n"),a},Eden.RuntimeError.prototype.prettyPrint=function(){return this.extra&&this.extra.stack?"Run-time Error:\n"+this.extra.stack:"Run-time Error:\n"},Eden.Selectors={cache:{}},Eden.Selectors.getScriptBase=function(a){for(var b=a;b.parent;)b=b.parent;return b.base.origin.name},Eden.Selectors.buildScriptTree=function(a){for(var b={},c=0;c ")},Eden.Selectors.getPath=function(a){},Eden.Selectors.testType=function(a){if("binaryop"==a.type)switch(a.op){case"+":case"-":case"/":case"*":case"^":case"%":return"number";case"//":return"list";case"==":case"<":case">":case"<=":case">=":case"||":case"&&":case"!=":return"boolean";default:return"unknown"}else if("literal"==a.type)switch(a.datatype){case"NUMBER":return"number";case"BOOLEAN":return"boolean";case"STRING":return"string";case"LIST":return"list";default:return"unknown"}return"unknown"},Eden.Selectors.getChildren=function(a,b){var c=[];if(void 0===a)return c;for(var d=0;da[d].depth);)"dummy"!=e.type&&(c.push(e),f.push(e)),e=e.nextSibling;b&&c.push.apply(c,Eden.Selectors.getChildren(f,b))}return c=c.filter(function(a){return"dummy"!=a.type})},Eden.Selectors.allowedOptions={external:!0,history:!0,all:!0,indexed:!0,index:!0,nosort:!0,remote:!0},Eden.Selectors.resultTypes={brief:!0,comment:!0,source:!0,innersource:!0,title:!0,path:!0,name:!0,symbol:!0,line:!0,depends:!0,value:!0,tags:!0,rawcomment:!0,id:!0,remote:!0,root:!0,enabled:!0,executed:!0,exprtree:!0},Eden.Selectors.expressionToLists=function(a){switch(a.type){case"binaryop":return[Eden.Selectors.expressionToLists(a.l),a.op,Eden.Selectors.expressionToLists(a.r)];case"ternaryop":return[Eden.Selectors.expressionToLists(a.first),"if",Eden.Selectors.expressionToLists(a.condition),"else",Eden.Selectors.expressionToLists(a.second)];case"unaryop":return[a.op,Eden.Selectors.expressionToLists(a.r)];case"length":return[Eden.Selectors.expressionToLists(a.l),"#"];case"index":return Eden.Selectors.expressionToLists(a.expression)}if(console.log(a),"functioncall"==a.type){console.log("FUNCCALL");for(var b=[],c=0;c0;break;case"historic":i=f.executed==-1;break;case"tags":f.doxyComment&&(i=f.doxyComment.getHashTags());break;case"rawcomment":f.doxyComment&&(i=f.doxyComment.content);break;case"controls":case"id":i=f.id;break;case"path":i=Eden.Selectors.getID(f);break;case"remote":for(var l=f;l.parent;)l=l.parent;if(!l.base||!l.base.origin){i=!1;break}i=l.base.origin.remote;break;case"root":i=void 0===f.parent}g.push(i)}c.length>1?d.push(g):1==c.length&&g.length>0&&d.push(g[0])}return d}return a},Eden.Selectors.outerBracket=function(a){for(var b=0,c=0;c0&&"@"==a.charAt(0);){c||(c={}),a=a.substring(1);var d=a.search(/[^a-z]+/);d==-1&&(d=a.length);var e=a.substring(0,d);a=a.substring(d).trim(),c[e]=!0}return Eden.Selectors._parse(a,c)}},Eden.Selectors._parse=function(a,b){var c;if(a&&""!=a){if(">"==a.charAt(0))">"==a.charAt(1)?(c=new Eden.Selectors.NavigateNode(">",(!0)),a=a.substring(2).trim()):(c=new Eden.Selectors.NavigateNode(">",(!1)),a=a.substring(1).trim());else if("<"==a.charAt(0))"<"==a.charAt(1)?(c=new Eden.Selectors.NavigateNode("<",(!0)),a=a.substring(2).trim()):(c=new Eden.Selectors.NavigateNode("<",(!1)),a=a.substring(1).trim());else if(","==a.charAt(0))c=new Eden.Selectors.UnionNode,a=a.substring(1).trim();else if(":"==a.charAt(0)||"."==a.charAt(0)){var d=a.substring(1),e=d.search(/[^a-zA-Z0-9\-]/);e==-1?e=a.length:e++;var f=a.substring(0,e),g=void 0;if(e]/);j==-1&&(j=a.length);var k=a.substring(0,j).trim();if(k.startsWith("plugins")){for(var l=a.split(">"),m="",n=0;n0){for(var c=0;c0?c(0):b&&b()})},Eden.Selectors.goto=function(a){Eden.Selectors.query(a,void 0,{minimum:1,noindex:!0},function(b){if(0==b.length)return!1;for(var c=[b[0]],d=b[0];d.parent;)c.push(d.parent),d=d.parent;for(var e=!1,f=0;f":this.compare="="==b.charAt(1)?">=":">";break;case"=":this.compare="=";break;case"!":this.compare="!="}if(this.compare)switch(this.compare){case"!":case"=":case">":case"<":this.value=b.substring(1);break;case">=":case"<=":this.value=b.substring(2)}if(this.isreg?this.value=Eden.Selectors.makeRegex(this.value):null!==b.match(/^[0-9]+\-[0-9]+$/)?this.range=!0:null!==b.match(/^[0-9]+$/)&&(this.value=parseInt(b)),".type"==this.name)switch(this.param){case"is":this.param="definition";break;case"assign":case"=":this.param="assignment";break;case"call":this.param="functioncall";break;case"proc":this.param="action";break;case"action":this.param="script";break;case"+=":case"-=":case"*=":case"/=":case"++":case"--":this.param="modify"}}},Eden.Selectors.PropertyNode.attributes={name:{local:!1,indexed:!0,rank:1},type:{local:!1,indexed:!1,rank:3},datatype:{local:!1,indexed:!1,rank:30},id:{local:!1,indexed:!0,rank:2},lines:{local:!1,indexed:!1,rank:3},depends:{local:!1,indexed:!1,rank:4},time:{local:!0,indexed:!1,rank:3},date:{local:!1,indexed:!1,rank:3},title:{local:!1,indexed:!1,rank:10},author:{local:!1,indexed:!1,rank:10},v:{local:!1,indexed:!1,rank:20},version:{local:!1,indexed:!1,rank:20},source:{local:!0,indexed:!1,rank:50},comment:{local:!0,indexed:!1,rank:50}},Eden.Selectors.PropertyNode.pseudo={line:{local:!1,indexed:!1,rank:50},determines:{local:!0,indexed:!0,rank:10},first:{local:!1,indexed:!0,rank:5},last:{local:!1,indexed:!0,rank:5},unexecuted:{local:!0,indexed:!1,rank:3},executed:{local:!0,indexed:!1,rank:3},root:{local:!1,indexed:!0,rank:3},project:{local:!0,indexed:!0,rank:3},nth:{local:!1,indexed:!0,rank:5},value:{local:!0,indexed:!1,rank:50},matches:{local:!1,indexed:!1,rank:100},age:{local:!1,indexed:!1,rank:6},remote:{local:!0,indexed:!0,rank:20},not:{local:!1,indexed:!1,rank:100},active:{local:!0,indexed:!1,rank:10},me:{local:!1,indexed:!1,rank:20},listed:{local:!1,indexed:!1,rank:20}},Eden.Selectors.PropertyNode.prototype.append=function(a){if(!a)return this;switch(a.type){case"property":case"tag":case"name":var b=new Eden.Selectors.IntersectionNode(this,a);return b.options=this.options,b;case"union":case"intersection":return a.prepend(this),a;case"navigate":return a.prepend(this),a}return this},Eden.Selectors.PropertyNode.prototype.prepend=function(a){if(!a)return this;switch(a.type){case"property":case"tag":case"name":var b=new Eden.Selectors.IntersectionNode(a,this);return b.options=this.options,b;case"union":case"intersection":return a.append(this),a;case"navigate":return a.append(this),a}return this},Eden.Selectors.PropertyNode.prototype.filter=function(a){a||(a=this.construct());var b=this,c=this.value,d=this.name;if("number"==typeof this.name)return a&&a.length>=this.name?[a[this.name-1]]:[];switch(d){case".name":if(!c)return a.filter(function(a){return void 0!==a.lvalue||void 0!==a.name});var e=edenUI.regExpFromStr(c);return a.filter(function(a){return a.lvalue&&e.test(a.lvalue.name)||a.name&&e.test(a.name)});case".id":return a.filter(function(a){return 0==a.id&&a.buildID(),a.id==c});case".type":if(!c)break;return a.filter(function(a){return a.type==c});case".datatype":return a.filter(function(a){return a.expression&&Eden.Selectors.testType(a.expression)==c||a.expression&&"scope"==a.expression.type&&a.expression.range&&"list"==c});case".lines":return a;case":line":return a;case".op":case".operator":return a;case":pattern":return a;case":determines":return a;case".depends":return a.filter(function(a){return("definition"==a.type||"when"==a.type)&&a.dependencies[c]});case":active":return a.filter(function(a){if("definition"==a.type||"assignment"==a.type){var b=eden.root.symbols[a.lvalue.name];return b&&(b.origin===a||b.origin&&b.origin.id==a.id)}return"when"==a.type&&a.enabled});case":first":return a.length>0?[a[0]]:[];case":last":return a.length>0?[a[a.length-1]]:[];case":unexecuted":return a.filter(function(a){return 0==a.executed});case":executed":return a.filter(function(a){return 1==a.executed});case":root":return a.filter(function(a){return void 0===a.parent});case":project":return[eden.project.ast.script];case":nth":return a.filter(function(a){return a.parent&&Eden.Selectors.getChildren([a.parent],!1)[b.value-1]===a});case":value":return a;case":":case":matches":var f=Eden.Selectors.parse(this.param);return f?f.filter(a):[];case".title":return this.isreg?a.filter(function(a){if(!a.doxyComment)return!1;var c=a.doxyComment.getProperty("title");return c&&b.value.test(c)}):a.filter(function(a){if(!a.doxyComment)return!1;var c=a.doxyComment.getProperty("title");return c&&c==b.value});case".author":return a;case".version":return a;case".source":return this.isreg?a.filter(function(a){return b.value.test(a.getSource())}):a.filter(function(a){return a.getSource()==b.value});case".comment":return this.isreg?a.filter(function(a){return a.doxyComment&&b.value.test(a.doxyComment.stripped())}):a.filter(function(a){return a.doxyComment&&a.doxyComment.stripped()==b.value});case":age":var g=generateTimeStamp(this.value),h=Date.now(),i=h-g;return console.log("AGE",g,h,i),void 0===this.compare||"<"==this.compare?a.filter(function(a){return a.stamp>i}):a.filter(function(a){return a.stamp=0})},Eden.Selectors.NameNode=function(a){this.type="name",this.name=a,this.options=void 0,this.isreg="/"==a.charAt(0)||a.indexOf("*")!=-1,this.local=!1},Eden.Selectors.NameNode.prototype.filter=function(a){if(!a)return this.construct();var b=this.name;if(this.isreg){var c=Eden.Selectors.makeRegex(this.name);return a.filter(function(a){return a.lvalue&&c.test(a.lvalue.name)||a.name&&c.test(a.name)})}return a.filter(function(a){return a.lvalue&&a.lvalue.name==b||a.name&&a.name==b})},Eden.Selectors.NameNode.prototype.construct=function(){if(this.isreg){var a=Eden.Selectors.makeRegex(this.name);stats=Eden.Index.getByNameRegex(a)}else{stats=Eden.Index.getByName(this.name);for(var b=this.name.toLowerCase().split(" "),c=Eden.Index.getByTag("#"+b[0]),d=1;d=0})},Eden.Selectors.NameNode.prototype.append=Eden.Selectors.PropertyNode.prototype.append,Eden.Selectors.NameNode.prototype.prepend=Eden.Selectors.PropertyNode.prototype.prepend,Eden.Selectors.TagNode=function(a){this.type="tag",this.tag=a,this.options=void 0,this.isreg=a.indexOf("*")!=-1,this.local=!1},Eden.Selectors.TagNode.prototype.filter=function(a){if(!a)return this.construct();var b=this;return a.filter(function(a){return a.doxyComment&&a.doxyComment.hasTag(b.tag)})},Eden.Selectors.TagNode.prototype.construct=function(){if(this.isreg){var a=Eden.Selectors.makeRegex(this.tag);stats=Eden.Index.getByTagRegex(a)}else stats=Eden.Index.getByTag(this.tag);return this.options&&this.options.history?stats:stats.filter(function(a){return a.executed>=0})},Eden.Selectors.TagNode.prototype.append=Eden.Selectors.PropertyNode.prototype.append,Eden.Selectors.TagNode.prototype.prepend=Eden.Selectors.PropertyNode.prototype.prepend,Eden.Selectors.IntersectionNode=function(a,b){this.type="intersection",this.children=[a,b], +this.local=!1},Eden.Selectors.IntersectionNode.prototype.append=function(a){if(!a)return this;switch(a.local&&(this.local=!0),a.type){case"navigate":return a.prepend(this),a}return this.children.push(a),this},Eden.Selectors.IntersectionNode.prototype.prepend=function(a){return a?(a.local&&(this.local=!0),this.children.splice(0,0,a),this):this},Eden.Selectors.IntersectionNode.prototype.filter=function(a,b){for(var c=0;c"==this.direction){if(!a&&void 0===this.left)return this.right?this.right.filter(a,b).filter(function(a){return void 0!==a.parent}):Eden.Index.getAll().filter(function(a){return void 0!==a.parent});var c;return c=void 0===this.left?Eden.Selectors.getChildren(a,this.deep):Eden.Selectors.getChildren(this.left.filter(a,b),this.deep),this.right?this.right.filter(c,b):c}if("<"==this.direction){if(!a&&void 0===this.left)return this.right?this.right.filter(a,b).filter(function(a){return"script"==a.type||"when"==a.type||"if"==a.type||"for"==a.type}):Eden.Index.getAll().filter(function(a){return"script"==a.type||"when"==a.type||"if"==a.type||"for"==a.type});var c;if(c=void 0===this.left?a.filter(function(a){return"script"==a.type||"when"==a.type||"if"==a.type||"for"==a.type}):this.left.filter(a,b),this.deep){for(var d=[],e=0;e=0&&Eden.Index.name_index[d].splice(e,1)}if(a.tags)for(var f=a.tags,c=0;c=0&&Eden.Index.tag_index[f[c]].splice(e,1)}}}},Eden.Index.update=function(a){if(void 0===Eden.Index.id_index[a.id]&&(Eden.Index.id_index[a.id]=[]),Eden.Index.id_index[a.id].push(a),1==Eden.Index.id_index[a.id].length){if(void 0===Eden.Index.type_index[a.type]&&(Eden.Index.type_index[a.type]={}),Eden.Index.type_index[a.type][a.id]=!0,a.name&&"do"!=a.type||a.lvalue){var b=a.name?a.name:a.lvalue.name;void 0===Eden.Index.name_index[b]&&(Eden.Index.name_index[b]=[]),Eden.Index.name_index[b].indexOf(a.id)==-1&&Eden.Index.name_index[b].push(a.id)}if(a.tags)for(var c=a.tags,d=0;d0&&this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.debug=!1,Eden.AST.debugstep=!1,Eden.AST.debugstep_cb=void 0,Eden.AST.debugspeed=500,Eden.AST.debugbreakpoint=void 0,Eden.AST.debugbreakpoint_cb=void 0,Eden.AST.debug_begin_cb=void 0,Eden.AST.debug_end_cb=void 0,Eden.AST.fromNode=function(a,b){var c=new Eden.AST(a.getInnerSource(),(void 0),b,{noindex:!0,noparse:!0});return c.script=a,c.whens=Eden.Selectors.queryWithin([a],">>.type(when)"),c.errors=a.errors,c},Eden.AST.prototype.doxyFromOrigin=function(){var a=this.origin.name;if(this.origin.title&&(a+="\n * @title "+this.origin.title),this.origin.author&&(a+="\n * @author "+this.origin.author),this.origin.id&&(a+="\n * @id "+this.origin.id),this.origin.saveID&&(a+="\n * @version "+this.origin.vid),this.origin.tags&&this.origin.tags.length>0){a+="\n *";for(var b=0;b>"),b=0;b0&&(this.lines[a].executed=0)},Eden.AST.prototype.executeLine=function(a,b,c){var d,e=a;d=a==-1?this.script:this.lines[e],void 0!==d&&(d=this.getBase(d),this.executeStatement(d,e,b,c))},Eden.AST.parseStatement=function(a,b){var c=new Eden.AST(a,(void 0),b?b:{},{noparse:!0,noindex:!0});c.next();var d=c.pSTATEMENT();d.base=c,d.setSource(0,a.length,a),d.stamp=c.stamp;var e=a.match("\n");return null===e?d.numlines=0:d.numlines=e.length,d},Eden.AST.parseScript=function(a,b){var c=new Eden.AST(a,(void 0),b?b:{},{noparse:!0,noindex:!0});c.next();var d=c.pSCRIPT();d.base=c,d.setSource(0,a.length,a),d.stamp=c.stamp;var e=a.match("\n");return null===e?d.numlines=0:d.numlines=e.length,d},Eden.AST.parseExpression=function(a){var b=new Eden.AST(a,(void 0),{},{noparse:!0,noindex:!0});b.next();var c=b.pEXPRESSION();return c},Eden.AST.registerStatement=function(a){a.prototype.getOrigin=Eden.AST.BaseStatement.getOrigin,a.prototype.hasErrors=Eden.AST.BaseStatement.hasErrors,a.prototype.setSource=Eden.AST.BaseStatement.setSource,a.prototype.getSource=Eden.AST.BaseStatement.getSource,a.prototype.getOuterSource=Eden.AST.BaseStatement.getOuterSource,a.prototype.getNumberOfLines=Eden.AST.BaseStatement.getNumberOfLines,a.prototype.getStartLine=Eden.AST.BaseStatement.getStartLine,a.prototype.getEndLine=Eden.AST.BaseStatement.getEndLine,a.prototype.getRange=Eden.AST.BaseStatement.getRange,a.prototype.error=Eden.AST.fnEdenASTerror,a.prototype.addIndex=Eden.AST.BaseStatement.addIndex,a.prototype.removeIndex=Eden.AST.BaseStatement.removeIndex,a.prototype.destroy=Eden.AST.BaseStatement.destroy,a.prototype.buildID=Eden.AST.BaseStatement.buildID,a.prototype.setDoxyComment=Eden.AST.BaseStatement.setDoxyComment},Eden.AST.registerScript=function(a){Eden.AST.registerStatement(a),a.prototype.getStatementByLine=Eden.AST.BaseScript.getStatementByLine,a.prototype.getRelativeLine=Eden.AST.BaseScript.getRelativeLine,a.prototype.getNumberOfLines=Eden.AST.BaseScript.getNumberOfLines,a.prototype.append=Eden.AST.BaseScript.append,a.prototype.appendChild=Eden.AST.BaseScript.appendChild,a.prototype.removeChild=Eden.AST.BaseScript.removeChild,a.prototype.insertBefore=Eden.AST.BaseScript.insertBefore,a.prototype.insertAfter=Eden.AST.BaseScript.insertAfter,a.prototype.replaceChild=Eden.AST.BaseScript.replaceChild,a.prototype.addIndex=Eden.AST.BaseScript.addIndex,a.prototype.removeIndex=Eden.AST.BaseScript.removeIndex,a.prototype.destroy=Eden.AST.BaseScript.destroy,a.prototype.buildID=Eden.AST.BaseScript.buildID},Eden.AST.registerContext=function(a){Eden.AST.registerScript(a)},Eden.AST.prototype.getBase=function(a,b){void 0===b&&console.error("Undefined context in getBase");for(var c=a;c&&c.parent&&c.parent!==b;)c=c.parent;return c},Eden.AST.prototype.getBlockLines=function(a,b){for(var c=a,d=this.getBase(this.lines[c],b);c>0&&this.lines[c-1]&&this.getBase(this.lines[c-1],b)==d;)c--;for(var e=c;c0},Eden.AST.prototype.prettyPrint=function(){var a="";if(this.script.errors.length>0)for(var b=0;b0);)this.token=this.stream.readToken(),"/*"==this.token?b++:"*/"==this.token&&b--;if("*/"!=this.token){var f=new Eden.SyntaxError(this,Eden.SyntaxError.BLOCKCOMMENT);f.line=e,this.errors.push(f)}if(c){var g=new Eden.AST.DoxyComment(this.stream.code.substring(d+3,this.stream.position-2).trim(),e,this.stream.line);this.lastDoxyComment.push(g),g.parent=this.parentDoxy,g.content.endsWith("@{")?this.parentDoxy=g:g.content.startsWith("@}")&&this.parentDoxy&&(this.parentDoxy=this.parentDoxy.parent)}this.token=this.stream.readToken()}else{if("${{"!=this.token)break;var d=this.stream.position,e=this.stream.line;for(this.data.line=e;this.stream.valid()&&"}}$"!=this.token;)this.token=this.stream.readToken();this.data.value=this.stream.code.substring(d,this.stream.position-3),this.token="JAVASCRIPT",this.stream.prevposition=d-3}this.stream.prevline=a},Eden.AST.prototype.peekNext=function(a){var b,c={value:""};for(this.stream.data=c,this.stream.pushPosition();a>0;)b=this.stream.readToken(),a--;return this.stream.popPosition(),this.stream.data=this.data,b},Eden.AST.BaseStatement=function(){this.start=0,this.end=0,this.parent=void 0,this.errors=[],this.warning=void 0,this.executed=0,this.numlines=-1,this.doxyComment=void 0,this.lock=0,this.source=void 0,this.id=0,this.stamp=0,this.nextSibling=void 0,this.previousSibling=void 0,this.tags=void 0},Eden.AST.BaseStatement.setDoxyComment=function(a){this.doxyComment=a,a&&(void 0===this.tags?this.tags=a.getHashTags():this.tags=this.tags.concat(a.getHashTags()))},Eden.AST.BaseStatement.buildID=function(){var a,b=0,c=this.source;this.doxyComment&&(c=this.doxyComment.content+c);for(var d=c.length,e=0;e0},Eden.AST.BaseStatement.getNumberOfLines=function(){return this.numlines},Eden.AST.BaseStatement.getStartLine=function(a){return this.parent?this.parent.getRelativeLine(this,a):-1},Eden.AST.BaseStatement.getEndLine=function(a){return this.getStartLine(a)+this.getNumberOfLines()},Eden.AST.BaseStatement.getRange=function(a){var b=this.getStartLine(a);return[b,b+this.getNumberOfLines()]},Eden.AST.BaseStatement.setSource=function(a,b,c){this.start=a,this.end=b,this.source=c},Eden.AST.BaseStatement.getSource=function(){return this.source},Eden.AST.BaseStatement.getOuterSource=function(){var a=this.getSource();void 0===this.parent&&(a="action "+this.name+"{"+a+"}"),this.doxyComment&&(a="/** "+this.doxyComment.content+" */\n"+a);for(var b=this.parent;b;)"script"==b.type?(a=b.name?"action "+b.name+" {\n"+a+"\n}":"{\n"+a+"\n}",b.doxyComment&&(a="/** "+b.doxyComment.content+" */\n"+a),b=b.parent):b=void 0;return a},Eden.AST.BaseStatement.getOrigin=function(){for(var a=this;a.parent;)a=a.parent;return a.base?a.base.origin:void 0},Eden.AST.BaseScript=function(){Eden.AST.BaseStatement.apply(this),this.statements=[],this.parameters=void 0,this.locals=void 0,this.indexed=!1},Eden.AST.BaseScript.appendChild=function(a){this.statements.push(a),this.statements.length>1&&(a.previousSibling=this.statements[this.statements.length-2],this.statements[this.statements.length-2].nextSibling=a),a.parent=this,this.indexed&&0!=this.id&&console.log("INVALIDATE ID",this),"dummy"!=a.type&&this.indexed&&a.addIndex(),a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.BaseScript.append=Eden.AST.BaseScript.appendChild,Eden.AST.BaseScript.insertAfter=function(a,b){var c;for(c=0;c0&&this.errors.push.apply(this.errors,b.errors),this.indexed&&0!=this.id&&console.log("INVALIDATE ID",this)},Eden.AST.BaseScript.insertBefore=function(a,b){var c;for(c=0;c0&&this.errors.push.apply(this.errors,b.errors),void(this.indexed&&0!=this.id&&console.log("INVALIDATE ID",this))):void eden.emit("error",[new Eden.RuntimeError((void 0),Eden.RuntimeError.NOCHILD,this,"Statement is not a child when using insertBefore")])},Eden.AST.BaseScript.removeChild=function(a){var b;for(b=0;b=this.statements.length)return void eden.emit("error",[new Eden.RuntimeError((void 0),Eden.RuntimeError.NOCHILD,this,"Statement is not a child when using replaceChild")]);c=d}b.nextSibling=this.statements[c].nextSibling,b.nextSibling&&(b.nextSibling.previousSibling=b),b.previousSibling=this.statements[c].previousSibling,b.previousSibling&&(b.previousSibling.nextSibling=b),this.statements[c].destroy(),this.statements[c]=b,b.parent=this,"dummy"!=b.type&&this.indexed&&b.addIndex(),this.indexed&&0!=this.id&&console.log("INVALIDATE ID",this)},Eden.AST.BaseScript.destroy=function(){this.executed<1&&Eden.Index.remove(this);for(var a=0;aa)&&void 0!==this.statements)for(var d=0;d=c&&a<=c+e&&"dummy"!=this.statements[d].type)return this.statements[d];c+=e}},Eden.AST.BaseScript.getRelativeLine=function(a,b){var c=0;b&&b!==this&&this.parent&&(c=this.parent.getRelativeLine(this,b));for(var d=0;d0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Append.prototype.setIndex=function(a){this.index=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Append.prototype.generate=function(a,b){var c=this.index.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type}),d=this.destination.generate(a,b);return this.destination.islocal?d+".push("+c+");\n":b+".mutate("+d+", function(s) { scope.lookup(s.name).value.push("+c+"); }, this);"},Eden.AST.Append.prototype.execute=function(a,b,c,d){this.executed=1;var e=this.index.execute(a,b,c);e instanceof BoundValue&&(e=e.value);var f=eden.root.lookup(this.destination.name),g=f.value(c);g.push(e),f.assign(g,c,this)},Eden.AST.registerStatement(Eden.AST.Append),Eden.AST.Assignment=function(a){this.type="assignment",Eden.AST.BaseContext.apply(this),this.errors=a?a.errors:[],a&&a.warning&&(this.warning=a.warning),this.expression=a,this.lvalue=void 0,this.compiled=void 0,this.dirty=!1,this.value=void 0,this.compiled=void 0},Eden.AST.Assignment.prototype.left=function(a){this.lvalue=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Assignment.prototype.generate=function(a,b){var c=this.lvalue.generate(a,b);return this.lvalue.islocal?(c+=" = ",c+=this.expression.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type}),c+=";\n"):this.lvalue.hasListIndices()?(c=b+".listAssign("+c+",",c+=this.expression.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type}),c+=", Symbol.localJSAgent, false, ",c+=this.lvalue.generateCompList(a,b),c+=");\n"):(c=b+".assign("+c+",",c+=this.expression.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type}),c+=", Symbol.localJSAgent);\n")},Eden.AST.Assignment.prototype.compile=function(ctx){if(!this.compiled||this.dirty){this.dirty=!1,ctx?ctx.scopes=this.scopes:ctx=this;var rhs="(function(context,scope,cache,ctx) { \n",express=this.expression.generate(ctx,"scope",{bound:!0});if(ctx&&ctx.dirty&&(ctx.dirty=!1,this.dirty=!0),this.scopes.length>0){rhs+="\tvar _scopes = [];\n";for(var i=0;i0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.After.prototype.setStatement=function(a){this.statement=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.After.prototype.generate=function(a,b){void 0===b&&(b="eden.root.scope");var c="(function() {"+this.statement.generate(a,b,{bound:!1})+"})",d=this.expression.generate(a,b,{bound:!1});return"setTimeout("+c+", "+d+");\n"},Eden.AST.After.prototype.execute=function(ctx,base,scope){var statement="(function() { var scope = eden.root.scope;\n"+this.statement.generate(ctx,"root.scope")+"})";setTimeout(eval(statement),this.expression.execute(ctx,base,scope))},Eden.AST.registerStatement(Eden.AST.After),Eden.AST.BinaryOp=function(a){this.type="binaryop",this.op=a,this.errors=[],this.l=void 0,this.r=void 0,this.warning=void 0,"&"==this.op||"and"==this.op?this.op="&&":"|"!=this.op&&"or"!=this.op||(this.op="||")},Eden.AST.BinaryOp.prototype.left=Eden.AST.fnEdenASTleft,Eden.AST.BinaryOp.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.BinaryOp.prototype.setRight=function(a){this.r=a,this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.BinaryOp.prototype.generate=function(a,b,c){var d,e={bound:!1,usevar:c.usevar},f=this.l.generate(a,b,e),g=this.r.generate(a,b,e);switch(this.op){case"//":d="concat";break;case"+":d="add";break;case"-":d="subtract";break;case"/":d="divide";break;case"*":d="multiply";break;case"==":d="equal";break;case"%":d="mod";break;case"^":d="pow";break;default:d="RAW"}var h;return h="RAW"!=d?"rt."+d+"(("+f+"),("+g+"))":"("+f+") "+this.op+" ("+g+")",c.bound?"new BoundValue("+h+", "+b+")":h},Eden.AST.BinaryOp.prototype.execute=function(ctx,base,scope){var rhs="(function(context,scope) { return ";return rhs+=this.generate(ctx,"scope",{bound:!1}),rhs+=";})",eval(rhs)(eden.root,scope)},Eden.AST.Break=function(){this.type="break",Eden.AST.BaseStatement.apply(this)},Eden.AST.Break.prototype.generate=function(a,b){return"break; "},Eden.AST.Break.prototype.execute=function(a,b,c,d){var e=new Eden.RuntimeError(b,Eden.RuntimeError.NOTSUPPORTED,this,"Break not supported here");e.line=this.line,this.errors.push(e),Eden.Agent.emit("error",[d,e])},Eden.AST.registerStatement(Eden.AST.Break),Eden.AST.Case=function(){this.type="case",Eden.AST.BaseStatement.apply(this),this.datatype="",this.literal=void 0},Eden.AST.Case.prototype.setLiteral=function(a,b){this.datatype=a,this.literal=b},Eden.AST.Case.prototype.generate=function(a,b){return"string"==typeof this.literal?'case "'+this.literal+'": ':"case "+this.literal+": "},Eden.AST.Case.prototype.execute=function(a,b,c,d){var e=new Eden.RuntimeError(b,Eden.RuntimeError.NOTSUPPORTED,this,"Case not supported here");e.line=this.line,this.errors.push(e),Eden.Agent.emit("error",[d,e])},Eden.AST.registerStatement(Eden.AST.Case),Eden.AST.CodeBlock=function(){this.type="codeblock",Eden.AST.BaseContext.apply(this),this.params=void 0,this.locals=void 0,this.script=void 0},Eden.AST.CodeBlock.prototype.setLocals=function(a){this.locals=a,this.errors.push.apply(this.errors,a.errors)},Eden.AST.CodeBlock.prototype.setParams=function(a){this.params=a,this.errors.push.apply(this.errors,a.errors)},Eden.AST.CodeBlock.prototype.setScript=function(a){this.script=a,a&&(a.parent=this,this.errors.push.apply(this.errors,a.errors))},Eden.AST.CodeBlock.prototype.generate=function(a){var b="(function(context, scope) {\n";if(this.locals&&this.locals.list)for(var c=0;c0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Definition.prototype.generateDef=function(a,b){var c="primary"==this.expression.type&&0==this.expression.extras.length||"scope"==this.expression.type,d="function(context, scope, cache) {\n";this.locals=a?a.locals:void 0,this.params=a?a.params:void 0,this.backtickCount=0;var e=this.expression.generate(this,"scope",{bound:c,indef:!0});if(this.backtickCount>0&&(d+="var btick = 0;\n"),this.scopes.length>0){d+="\tvar _scopes = [];\n";for(var f=0;f0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Delete.prototype.setIndex=function(a){this.index=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Delete.prototype.generate=function(a,b){var c=this.index.generate(a,b,{bound:!1}),d=this.destination.generate(a);return d+".mutate(scope, function(s) { scope.lookup(s.name).value.splice(rt.index("+c+"), 1); }, this);"},Eden.AST.Delete.prototype.execute=function(a,b,c){this.executed=1;var d=this.index.execute(a,b,c);d instanceof BoundValue&&(d=d.value),eden.root.lookup(this.destination.name).mutate(c,function(a){a.value().splice(d-1,1)},this)},Eden.AST.registerStatement(Eden.AST.Delete),Eden.AST.Do=function(){this.type="do",Eden.AST.BaseStatement.apply(this),this.name=void 0,this.script=void 0,this.parameters=[],this.params=[],this.scope=void 0,this.compScope=void 0,this.nscope=void 0,this.selector=void 0},Eden.AST.Do.prototype.addParameter=function(a){this.parameters.push(a),a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Do.prototype.setScript=function(a){this.script=a,this.script&&this.script.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Do.prototype.setName=function(a){a&&a.errors&&this.errors.push.apply(this.errors,a.errors),this.name=a},Eden.AST.Do.prototype.setScope=function(a){this.scope=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Do.prototype.getScope=function(ctx){if(this.scope&&void 0===this.compScope)try{this.compScope=eval("(function (context, scope) { var s = "+this.scope.generateConstructor(ctx,"scope")+"; s.rebuild(); return s; })")}catch(e){}return this.compScope},Eden.AST.Do.prototype.generate=function(a){return""},Eden.AST.Do.prototype.getParameters=function(a,b,c){for(var d=[],e=0;e0){c+='
Parameters:';for(var d=0;d
'+a.slice(1).join(" ")+"
"}c+=""}return c},Eden.AST.DoxyComment.prototype.getParamString=function(){var a=this.getControls()["@param"];if(a&&a.length>0){for(var b="(",c=0;c0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.FunctionCall.prototype.generate=function(a,b){if(void 0===this.lvalue){var c="(";if(this.params)for(var d=0;d0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Index.prototype.generate=function(a,b,c){var d=this.expression.generate(a,b,{bound:!1});return"[rt.index("+d+")]"},Eden.AST.Index.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Insert=function(){this.type="insert",Eden.AST.BaseStatement.apply(this),this.destination=void 0,this.index=void 0,this.value=void 0},Eden.AST.Insert.prototype.setDest=function(a){this.destination=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Insert.prototype.setIndex=function(a){this.index=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Insert.prototype.setValue=function(a){this.value=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Insert.prototype.generate=function(a,b){var c=this.index.generate(a,b,{bound:!1}),d=this.value.generate(a,b,{bound:!1}),e=this.destination.generate(a);return this.destination.islocal?e+".splice(rt.index("+c+"), 0, ("+d+"));":e+".mutate(scope, function(s) { scope.lookup(s.name).value.splice(rt.index("+c+"), 0, ("+d+")); }, this);"},Eden.AST.Insert.prototype.execute=function(a,b,c){this.executed=1;var d=this.index.execute(a,b,c),e=this.value.execute(a,b,c);d instanceof BoundValue&&(d=d.value),e instanceof BoundValue&&(e=e.value),eden.root.lookup(this.destination.name).mutate(c,function(a){a.value().splice(d-1,0,e)},this)},Eden.AST.registerStatement(Eden.AST.Insert),Eden.AST.Length=function(){this.type="length",this.errors=[],this.l=void 0},Eden.AST.Length.prototype.left=Eden.AST.fnEdenASTleft,Eden.AST.Length.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Length.prototype.generate=function(a,b,c){var d=this.l.generate(a,b,{bound:!1,usevar:c.usevar});return c.bound?"new BoundValue(rt.length("+d+"), "+b+")":"rt.length("+d+")"},Eden.AST.Length.prototype.execute=function(a,b,c,d){return rt.length(this.l.execute(a,b,c,d))},Eden.AST.Literal=function(a,b){this.type="literal",Eden.AST.BaseStatement.apply(this),this.datatype=a,this.value=b},Eden.AST.Literal.prototype.generate=function(a,b,c){var d;switch(this.datatype){case"NUMBER":d=this.value;break;case"LIST":d="[";for(var e=0;e0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.LValue.prototype.setExpression=function(a){this.express=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.LValue.prototype.getSymbol=function(a,b,c){if(a&&a.locals&&"declarations"!=a.locals.type&&a.locals.hasOwnProperty(this.name))return this.islocal=!0,a.locals[this.name];if(this.name)return eden.root.lookup(this.name);if(this.primary){var d=this.primary.execute(a,b,c);return d instanceof BoundValue&&(d=d.value),d}if(this.express){var e=this.express.execute(a,b,c);return e instanceof BoundValue&&(e=e.value),eden.root.lookup(e)}},Eden.AST.LValue.prototype.hasListIndices=function(){return this.lvaluep&&this.lvaluep.length>0&&"index"==this.lvaluep[0].kind},Eden.AST.LValue.prototype.generateCompList=function(a,b){for(var c="[",d=0;d0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Modify.prototype.generate=function(a,b){var c=this.lvalue.generate(a),d=c;0==this.lvalue.islocal?d=b+".assign("+c+","+b+".value("+c+")":d+=" = "+c;var e;return this.expression&&(e=this.expression.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type})),"+="==this.kind?d+=" + "+e:"-="==this.kind?d+=" - "+e:"/="==this.kind?d+=" / "+e:"*="==this.kind?d+=" * "+e:"++"==this.kind?d+="+1":"--"==this.kind&&(d+="-1"),d+=0==this.lvalue.islocal?", Symbol.localJSAgent);\n":";\n"},Eden.AST.Modify.prototype.execute=function(ctx,base,scope,agent){var _scopes=[];this.executed=1;var sym=this.lvalue.getSymbol(ctx,base);if("++"==this.kind){var newval=sym.value(scope)+1;sym.assign(newval,scope,this)}else if("--"==this.kind){var newval=sym.value(scope)-1;sym.assign(newval,scope,this)}else{var rhs="(function(context,scope) { return ";rhs+=this.expression.generate(ctx,"scope",{bound:!1}),rhs+=";})";for(var context=eden.root,i=0;i0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Primary.prototype.generate=function(a,b,c){var d;if(a&&a.locals)if("declarations"==a.locals.type){if(a.locals.list.indexOf(this.observable)!=-1){d=this.observable;for(var e=0;e0&&(c+=".observe("+JSON.stringify(this.triggers)+");\n"),c},Eden.AST.Action.prototype.execute=function(ctx,base,scope,agent){this.executed=1,this.doxyComment&&eden.updateDictionary(this.name,this.doxyComment);var body=this.body.generate(ctx),sym=eden.root.lookup(this.name);this.triggers.length>0?sym.define(eval(body),this,[]).observe(this.triggers):sym.define(eval(body),this,[])},Eden.AST.registerStatement(Eden.AST.Action),Eden.AST.Range=function(a){this.type="range",this.parent=void 0,this.errors=a?a.errors:[],this.expression=a,this.lvalue=void 0,this.start=0,this.end=0},Eden.AST.Range.prototype.setSource=function(a,b){this.start=a,this.end=b},Eden.AST.Range.prototype.setSecond=function(a){this.second=a,a&&a.errors&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Range.prototype.left=function(a){this.lvalue=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Range.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Require=function(){this.type="require",Eden.AST.BaseStatement.apply(this),this.expression=void 0},Eden.AST.Require.prototype.setExpression=function(a){this.expression=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Require.prototype.generate=function(a){return"edenUI.loadPlugin("+this.expression.generate(a,"scope",{bound:!1})+");"},Eden.AST.Require.prototype.execute=function(a,b,c){this.executed=1,edenUI.loadPlugin(this.expression.execute(a,b,c))},Eden.AST.registerStatement(Eden.AST.Require),Eden.AST.Return=function(){this.type="return",Eden.AST.BaseStatement.apply(this),this.result=void 0},Eden.AST.Return.prototype.setResult=function(a){this.result=a,this.errors.push.apply(this.errors,a.errors)},Eden.AST.Return.prototype.generate=function(a,b){if(this.result){var c=this.result.generate(a,b,{bound:!1,usevar:"scriptexpr"==a.type});return"return "+c+";\n"}return"return;\n"},Eden.AST.Return.prototype.execute=function(a,b,c,d){var e=new Eden.RuntimeError(b,Eden.RuntimeError.NOTSUPPORTED,this,"Return not supported here");e.line=this.line,this.errors.push(e),Eden.Agent.emit("error",[d,e])},Eden.AST.registerStatement(Eden.AST.Return),Eden.AST.Scope=function(){this.type="scope",this.errors=[],this.range=!1,this.overrides={},this.expression=void 0},Eden.AST.Scope.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Scope.prototype.prepend=function(a){this.primary.prepend(a)},Eden.AST.Scope.prototype.setExpression=function(a){this.expression=a,a&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Scope.prototype.addOverride=function(a,b,c,d,e){this.errors.push.apply(this.errors,a.errors),e&&(this.range=!0),d?(this.range=!0,this.overrides[a.observable]={start:b,end:d,increment:c,components:a.components,isin:e},this.errors.push.apply(this.errors,b.errors),this.errors.push.apply(this.errors,c.errors),this.errors.push.apply(this.errors,d.errors)):c?(this.range=!0,this.overrides[a.observable]={start:b,end:c,components:a.components,isin:e},this.errors.push.apply(this.errors,b.errors),this.errors.push.apply(this.errors,c.errors)):b&&(this.overrides[a.observable]={start:b,end:void 0,components:a.components,isin:e},this.errors.push.apply(this.errors,b.errors))},Eden.AST.Scope.prototype.generateConstructor=function(a,b){var c;c="new Scope(context, "+b+", [";for(var d in this.overrides){var e,f=this.overrides[d];if(e=this.range?f.start.generate(a,b,{bound:!1}):f.start.generate(a,b,{bound:"primary"==f.start.type||"scope"==f.start.type}),c+='new ScopeOverride("'+d+'", '+e,f.end){var g=this.overrides[d].end.generate(a,b,{bound:!1});if(f.increment){var h=f.increment.generate(a,b,{ +bound:!1});c+=", "+g+", "+h+"),"}else c+=", "+g+"),"}else c+=", undefined, undefined, "+f.isin+"),"}return c=c.slice(0,-1),c+="], "+this.range+", this,true)"},Eden.AST.Scope.prototype.generate=function(a,b,c){if(a.scopes.push(this.generateConstructor(a,b)),this.range){var d="_scopes["+(a.scopes.length-1)+"]",e=this.expression.generate(a,"_scopes["+(a.scopes.length-1)+"].clone()",c),f="(function() {\n";return f+=d+".range = false;\n",f+="var results = [];\n",f+="var scoperesults = [];\n",f+="while(true) {\n",f+="var val = "+e,c.bound&&(f+=";\n\tif (val.value !== undefined) scoperesults.push(val.scope);\n\tval = val.value"),f+=";\n",f+="if (val !== undefined) results.push(val);\n",f+="if ("+d+".next() == false) break;\n",f+="}\n"+d+".range = true;\n",f+=c.bound?"if (cache) cache.scopes = scoperesults;\n return new BoundValue(results,"+d+");}).call(this)":"return results;}).call(this)"}return this.expression.generate(a,"_scopes["+(a.scopes.length-1)+"]",c)},Eden.AST.Scope.prototype.execute=function(ctx,base,scope){var context={scopes:[]},gen=this.generate(context,"scope",{bound:!1}),rhs="(function(context,scope) {\n";if(context.scopes.length>0){rhs+="\tvar _scopes = [];\n";for(var i=0;i0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.ScopePath.prototype.generate=function(a,b,c){var d=this.path.generate(a,b,{bound:!0,scopeonly:!0});return this.primary.generate(a,d,c)},Eden.AST.ScopePath.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.ScopePattern=function(){this.type="scopepattern",this.observable="NONAME",this.components=[],this.errors=[]},Eden.AST.ScopePattern.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.ScopePattern.prototype.setObservable=function(a){this.observable=a},Eden.AST.ScopePattern.prototype.addListIndex=function(a){this.components.push(a),a&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Script=function(){this.type="script",Eden.AST.BaseScript.apply(this),this.name=void 0,this.active=!1,this.base=void 0,this.prefix="",this.postfix=""},Eden.AST.registerScript(Eden.AST.Script),Eden.AST.Script.prototype.getActionByName=function(a){for(var b,c=0;c0?(a.replaceChild(d,c[e.id][0]),c[e.id].shift(),0==c[e.id].length&&delete c[e.id]):"dummy"!=e.type&&this.indexed&&e.addIndex()}for(var f in c)for(var g=c[f],d=0;d0){void 0===a.locals&&(a.locals={});for(var f=0;f0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.ScriptExpr.prototype.generate=function(a,b){for(var c="(function(escope) {\nescope.isolate = true;\nif (cache) cache.scope = escope;\nvar context = new Eden.AST.Context(context);\nescope.context = context;\n",d=0;d0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Subscribers.prototype.execute=function(a,b,c){},Eden.AST.Subscribers.prototype.setList=function(a){this.list=a},Eden.AST.registerStatement(Eden.AST.Subscribers),Eden.AST.Switch=function(){this.type="switch",Eden.AST.BaseStatement.apply(this),this.expression="",this.statement=void 0,this.compiled=void 0},Eden.AST.Switch.prototype.setExpression=function(a){this.expression=a,a&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Switch.prototype.setStatement=function(a){this.statement=a,this.errors.push.apply(this.errors,a.errors)},Eden.AST.Switch.prototype.generate=function(a,b){void 0===b&&(b="eden.root.scope");var c="switch(";return c+=this.expression.generate(a,b,{bound:!1}),c+=") "+this.statement.generate(a,b)},Eden.AST.Switch.prototype.getSelector=function(ctx){if(this.compiled)return this.compiled;var cond="(function(context,scope) { return ";return cond+=this.expression.generate(ctx,"scope",{bound:!1}),cond+=";})",this.compiled=eval(cond),this.compiled},Eden.AST.Switch.prototype.execute=function(a,b,c,d){var e=new Eden.RuntimeError(b,Eden.RuntimeError.NOTSUPPORTED,this,"Switch not supported here");e.line=this.line,this.errors.push(e),Eden.Agent.emit("error",[d,e])},Eden.AST.registerStatement(Eden.AST.Switch),Eden.AST.TernaryOp=function(a){this.type="ternaryop",this.op=a,this.errors=[],this.first=void 0,this.second=void 0,this.condition=void 0,this.warning=void 0},Eden.AST.TernaryOp.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.TernaryOp.prototype.setFirst=function(a){this.first=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.TernaryOp.prototype.setSecond=function(a){this.second=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.TernaryOp.prototype.setCondition=function(a){this.condition=a,a.errors.length>0&&this.errors.push.apply(this.errors,a.errors),a&&a.warning&&(this.warning=a.warning)},Eden.AST.TernaryOp.prototype.left=function(a){void 0===this.condition?this.condition=a:this.first=a,a&&a.warning&&(this.warning=a.warning)},Eden.AST.TernaryOp.prototype.generate=function(a,b,c){var d=this.condition.generate(a,b,{bound:!1,usevar:c.usevar}),e=this.first.generate(a,b,c),f=this.second.generate(a,b,c);return"(("+d+")?("+e+"):("+f+"))"},Eden.AST.TernaryOp.prototype.execute=function(ctx,base,scope){var rhs="(function(context,scope) { return ";return rhs+=this.generate(ctx,"scope",{bound:!1}),rhs+=";})",eval(rhs)(eden.root,scope)},Eden.AST.UnaryOp=function(a,b){this.type="unaryop",this.op=a,this.errors=b.errors,this.r=b},Eden.AST.UnaryOp.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.UnaryOp.prototype.generate=function(a,b,c){var d,e=this.r.generate(a,b,{bound:!1,usevar:c.usevar});return"!"==this.op?d="!("+e+")":"&"==this.op?(d="context.lookup("+e+")",console.log(d)):"-"==this.op?d="-("+e+")":"*"==this.op&&(d=e+".value("+b+")"),c.bound?"new BoundValue("+d+","+b+")":d},Eden.AST.UnaryOp.prototype.execute=function(ctx,base,scope){var rhs="(function(context,scope) { return ";return rhs+=this.generate(ctx,"scope",{bound:!1}),rhs+=";})",eval(rhs)(eden.root,scope)},Eden.AST.Wait=function(){this.type="wait",Eden.AST.BaseStatement.apply(this),this.delay=void 0,this.compiled_delay=void 0},Eden.AST.Wait.prototype.setDelay=function(a){this.delay=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Wait.prototype.compile=function(ctx){if(void 0!==this.delay&&!this.compiled_delay){var source="(function(context,scope) { return ";source+=this.delay.generate(ctx,"scope",{bound:!1}),source+=";})",this.compiled_delay=eval(source)}},Eden.AST.Wait.prototype.generate=function(a,b){return"yield "+this.delay+";"},Eden.AST.registerStatement(Eden.AST.Wait),Eden.AST.When=function(){this.type="when",Eden.AST.BaseContext.apply(this),this.name="*When",this.id=0,this.expression=void 0,this.active=!1,this.compiled=void 0,this.scope=void 0,this.compScope=void 0,this.local=!1,this.dirty=!1,this.statement=void 0,this.enabled=!1,this.statements=[]},Eden.AST.registerContext(Eden.AST.When),Eden.AST.When.prototype.addTrigger=function(a,b,c){var d=a.triggers[b];if(d){for(var e=0;e0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Query.prototype.setResultTypes=function(a){this.restypes=a},Eden.AST.Query.prototype.setModify=function(a,b){this.modexpr=a,this.kind=b,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Query.prototype.generate=function(a,b,c){var d="Eden.Selectors.query("+this.selector.generate(a,b,{bound:!1})+', "'+this.restypes.join(",")+'")';return console.log("QUERY",d),c.bound?"new BoundValue("+d+","+b+")":d},Eden.AST.Query.prototype.execute=function(a,b,c,d){if(this.executed=1,void 0===this.modexpr){var e=Eden.Selectors.query(this.selector.execute(a,b,c,d),this.restypes);b.lastresult=e}else{var f=this.selector.execute(a,b,c,d),g=this.modexpr.execute(a,b,c,d);switch(this.kind){case"=":Eden.Selectors.assign(f,this.restypes,g);break;case"+=":Eden.Selectors.append(f,this.restypes,g);break;case"//=":Eden.Selectors.concat(f,this.restypes,g)}}},Eden.AST.registerStatement(Eden.AST.Query),Eden.AST.Alias=function(){this.type="script",Eden.AST.BaseStatement.apply(this),this.name=void 0,this.active=!1,this.selector=void 0},Eden.AST.Alias.prototype.setName=function(a){this.name=a},Eden.AST.Alias.prototype.setSelector=function(a){this.selector=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Alias.prototype.execute=function(a,b,c,d){return Eden.Selectors.query(this.selector.execute(a,b,c,d))},Eden.AST.Alias.prototype.generate=function(a,b,c){},Eden.AST.registerStatement(Eden.AST.Alias),Object.defineProperty(Eden.AST.Alias.prototype,"statements",{get:function(){if(this.selector){var a=this.selector.execute(this,eden.project.ast,eden.root.scope,this);return Eden.Selectors.query(a)}return[]}}),Eden.AST.Alias.addIndex=function(){this.buildID(),Eden.Index.update(this)},Eden.AST.Alias.removeIndex=function(){Eden.Index.remove(this)},Eden.AST.Alias.destroy=function(){this.executed<1&&Eden.Index.remove(this),this.parent=void 0,this.executed=-1},Eden.AST.Indexed=function(){this.type="indexed",this.indexes=[],this.expression=void 0,this.errors=[]},Eden.AST.Indexed.prototype.left=Eden.AST.fnEdenASTleft,Eden.AST.Indexed.prototype.error=Eden.AST.fnEdenASTerror,Eden.AST.Indexed.prototype.setExpression=function(a){this.expression=a,a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Indexed.prototype.addIndex=function(a){this.indexes.push(a),a&&a.errors.length>0&&this.errors.push.apply(this.errors,a.errors)},Eden.AST.Indexed.prototype.generate=function(a,b,c){for(var d="",e=0;ethis.depth);)"dummy"!=f.type&&"script"!=f.type&&"section"!=f.type&&e.push(f),f=f.nextSibling;return e},Eden.AST.registerStatement(Eden.AST.Section),Eden.AST.Section.prototype.getRange=function(a){for(var b=this.getStartLine(a),c=this.nextSibling;c&&c.nextSibling&&("section"!=c.nextSibling.type||c.nextSibling.depth>this.depth);)c=c.nextSibling;c&&"dummy"==c.type&&(c=c.previousSibling);var d=c?c.getEndLine(a):b+this.getNumberOfLines();return[b,d]},Eden.AST.prototype.pACTIONBODY=function(){var a=new Eden.AST.CodeBlock,b=this.parent;return this.parent=a,"{"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONOPEN)),this.parent=b,a):(this.next(),a.setLocals(this.pLOCALS()),a.locals.errors.length>0?(this.parent=b,a):(a.setScript(this.pSCRIPT()),"}"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),this.parent=b,a):(this.next(),this.parent=b,a)))},Eden.AST.prototype.pAFTER=function(){var a=new Eden.AST.After;if("("!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.AFTEROPEN)),a;this.next();var b=this.pEXPRESSION();if(a.setExpression(b),a.errors.length>0)return a;if(")"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.AFTEROPEN)),a;this.next();var c=this.pSTATEMENT();return void 0===c&&a.error(new Eden.SyntaxError(this,Eden.SyntaxError.AFTERNOSTATEMENT)),a.setStatement(c),a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.DEPRECATED,"'after' should not be used, use 'wait' instead"),a},Eden.AST.prototype.pPARAMS=function(){var a=new Eden.AST.Declarations;for(a.kind="oracle";"para"==this.token||"oracle"==this.token;){this.next();var b=this.pOLIST();if(a.list.push.apply(a.list,b),0==b.length||"NONAME"==b[b.length-1])return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.PARAMNAME)),a;if(";"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.PARAMSEMICOLON)),a;this.next()}return a},Eden.AST.prototype.pLOCALS=function(){for(var a=new Eden.AST.Declarations;"auto"==this.token||"local"==this.token;){this.next();var b=this.pOLIST();if(a.list.push.apply(a.list,b),0==b.length||"NONAME"==b[b.length-1])return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LOCALNAME)),a;if(";"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LOCALSEMICOLON)),a;this.next()}return a},Eden.AST.prototype.pDO=function(){var a=new Eden.AST.Do,b=this.parent;if(this.parent=a,"{"==this.token){this.next();var c=this.pSCRIPT();return c.parent=a,"}"!=this.token?(a.setScript(c),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),this.parent=b,a):(this.next(),a.setScript(c),this.parent=b,"with"!=this.token&&"::"!=this.token||(this.next(),a.setScope(this.pSCOPE())),a)}if("OBSERVABLE"!=this.token&&"."!=this.token&&">>"!=this.token&&">"!=this.token&&"<"!=this.token&&"<<"!=this.token&&":"!=this.token&&"*"!=this.token&&"@"!=this.token&&"#"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.DONAME)),this.parent=b,a;var d=this.pCODESELECTOR();if(a.setName(d),a.errors.length>0)return this.parent=b,a;if("with"==this.token||"::"==this.token)this.next(),a.setScope(this.pSCOPE());else if(";"!=this.token)for(var e=this.pELIST(),f=0;f0)return this.parent=b,a;return";"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),this.parent=b,a):(this.next(),this.parent=b,a)},Eden.AST.prototype.pEXPRESSION_PPPPP=function(){if("#"==this.token)return this.next(),new Eden.AST.Length},Eden.AST.prototype.pEXPRESSION_PPPPPP=function(){if("?"==this.token){this.next();var a=new Eden.AST.TernaryOp("?");return a.setFirst(this.pEXPRESSION()),a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.DEPRECATED,"use of ? for 'if'."),a.errors.length>0?a:":"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.TERNIFCOLON)),a):(this.next(),a.setSecond(this.pEXPRESSION()),a)}if("if"==this.token){this.next();var a=new Eden.AST.TernaryOp("?");return a.setCondition(this.pEXPRESSION()),a.errors.length>0?a:"else"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.TERNIFCOLON)),a):(this.next(),a.setSecond(this.pEXPRESSION()),a)}},Eden.AST.prototype.pEXPRESSION_PLAIN=function(){for(var a=this.pTERM();"&&"==this.token||"||"==this.token||"&"==this.token||"|"==this.token||"and"==this.token||"or"==this.token;){var b=new Eden.AST.BinaryOp(this.token);this.next(),b.left(a),b.setRight(this.pTERM()),a=b}return a},Eden.AST.prototype.pEXPRESSION=function(){var a;if("{"==this.token){if(this.next(),a=this.pSCRIPTEXPR(),"}"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),a;this.next()}else a=this.pEXPRESSION_PLAIN();if("with"==this.token||"::"==this.token){this.next();var b=this.pSCOPE();return b.setExpression(a),b}return a},Eden.AST.prototype.pFACTOR=function(){if("("==this.token){this.next();var a=this.pEXPRESSION();if(a.errors.length>0)return a;if(")"!=this.token?a.error(new Eden.SyntaxError(this,Eden.SyntaxError.EXPCLOSEBRACKET)):this.next(),"["==this.token){var b=this.pINDEXED();return b.setExpression(a),b}return a}if("$"==this.token){this.next();var c=0;if("#"==this.token)c=-1;else if("NUMBER"!=this.token||this.data.value<1){var d=new Eden.AST.Parameter((-1));return d.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.PARAMNUMBER)),d}return c=this.data.value,this.next(),new Eden.AST.Parameter(c)}if("["==this.token){this.next();var e=[];"]"!=this.token&&(e=this.pELIST());for(var f=new Eden.AST.Literal("LIST",e),g=0;g0&&f.errors.push.apply(f.errors,e[g].errors);return f.errors.length>0?f:("]"!=this.token?f.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTLITCLOSE)):this.next(),f)}if("@"==this.token)return this.next(),new Eden.AST.Literal("UNDEFINED","@");if("JAVASCRIPT"==this.token){var h=new Eden.AST.Literal("JAVASCRIPT",this.data.value);return this.next(),h}if("NUMBER"==this.token){var h=new Eden.AST.Literal("NUMBER",this.data.value);return this.next(),h}if("?"==this.token){this.next();var i=this.pQUERY();if("["==this.token){var b=this.pINDEXED();return b.setExpression(i),b}return i}if("-"==this.token){this.next();var j=new Eden.AST.UnaryOp("-",this.pFACTOR());return j}if("<<"==this.token){if(this.next(),"OBSERVABLE"!=this.token){var h=new Eden.AST.Literal("STRING",this.data.value);return h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.HEREDOCTOKEN)),h}var k=this.data.value;if(10!=this.stream.get()){var h=new Eden.AST.Literal("STRING",this.data.value);return h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.HEREDOCTOKEN)),h}for(var l="";this.stream.valid();){var m=this.stream.position,n=this.stream.readLine();if(n.startsWith(k)){this.stream.position=m+3;break}l+=n}this.stream.valid()||this.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.NEWLINE)),this.next();var h=new Eden.AST.Literal("STRING",l.slice(0,-1).replace(/\\/g,"\\\\").replace(/"/g,'\\"'));return h}if("STRING"==this.token){var h=new Eden.AST.Literal("STRING",this.data.value);for(this.data.error||this.next();0==this.data.error&&"STRING"==this.token;)h.value+="\n"+this.data.value,this.next();return this.data.error&&("LINEBREAK"==this.data.value?h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LITSTRLINE)):h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LITSTRCLOSE))),h}if("BOOLEAN"==this.token){var h=new Eden.AST.Literal("BOOLEAN",this.data.value);return this.next(),h}if("CHARACTER"==this.token){var h=new Eden.AST.Literal("CHARACTER",this.data.value);return this.data.error?(""==this.data.value?h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LITCHAREMPTY)):h.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LITCHARCLOSE)),h):(this.next(),h)}if("!"==this.token||"not"==this.token){this.next();var o=this.pFACTOR();return new Eden.AST.UnaryOp("!",o)}if("&"==this.token){this.next();var p=this.pLVALUE();return new Eden.AST.UnaryOp("&",p)}if("*"==this.token){this.next();var p=this.pFACTOR();return new Eden.AST.UnaryOp("*",p)}var q=this.pPRIMARY();return q},Eden.AST.prototype.pFOR=function(){var a=new Eden.AST.For,b=this.parent;if(this.parent=a,"("!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FOROPEN)),this.parent=b,a;if(this.next(),";"==this.token)this.next();else{if(a.setStart(this.pSTATEMENT_P(!0)),a.errors.length>0)return this.parent=b,a;if("range"!=a.sstart.type&&";"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FORSTART)),this.parent=b,a;";"==this.token&&this.next()}if("range"!=a.sstart.type){if(";"==this.token)this.next();else{if(a.setCondition(this.pEXPRESSION()),a.errors.length>0)return this.parent=b,a;if(";"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FORCOND)),this.parent=b,a;this.next()}if(")"==this.token)this.next();else{if(a.setIncrement(this.pSTATEMENT_P()),a.errors.length>0)return this.parent=b,a;if(")"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FORCLOSE)),this.parent=b,a;this.next()}}else{if(")"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.FORCLOSE)),this.parent=b,a;this.next()}return a.setStatement(this.pSTATEMENT()),a.statement&&(a.statement.parent=a),a.parent=b,this.parent=b,a},Eden.AST.prototype.pFUNCTION=function(){var a=new Eden.AST.Function,b=this.parent;return this.parent=a,"OBSERVABLE"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCNAME)),this.parent=b,a):(a.name=this.data.value,this.next(),a.setBody(this.pFUNCBODY()),this.parent=b,a)},Eden.AST.prototype.pFUNCBODY=function(){var a=new Eden.AST.CodeBlock,b=this.parent;return this.parent=a,"{"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCOPEN)),this.parent=b,a):(this.next(),a.setParams(this.pPARAMS()),a.params.errors.length>0?(this.parent=b,a):(a.setLocals(this.pLOCALS()),a.locals.errors.length>0?(this.parent=b,a):(a.setScript(this.pSCRIPT()),"}"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCLOSE)),this.parent=b,a):(this.next(),this.parent=b,a))))},Eden.AST.prototype.pIF=function(){var a=new Eden.AST.If;a.parent=this.parent;var b=this.parent;return this.parent=a,"("!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.IFCONDOPEN)),this.parent=b,a):(this.next(),a.setCondition(this.pEXPRESSION()),a.errors.length>0?(this.parent=b,a):")"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.IFCONDCLOSE)),this.parent=b,a):(this.next(),a.setStatement(this.pSTATEMENT()),a.errors.length>0?(this.parent=b,a):void 0===a.statement?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.IFNOSTATEMENT)),this.parent=b,a):(a.setElse(this.pIF_P()),this.parent=b,a)))},Eden.AST.prototype.pIF_P=function(){if("else"==this.token)return this.next(),this.pSTATEMENT()},Eden.AST.prototype.pREQUIRE=function(){var a=new Eden.AST.Require,b=this.pEXPRESSION();return a.setExpression(b),a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.DEPRECATED,"require."),";"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a)},Eden.AST.prototype.pIMPORT=function(){var a=new Eden.AST.Import,b=this.pCODESELECTOR();return void 0===b||b.errors.length>0?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.IMPORTPATH)),a):(a.setPath(b),";"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a))},Eden.AST.prototype.pINSERT=function(){var a=new Eden.AST.Insert;return a.setDest(this.pLVALUE()),a.errors.length>0?a:","!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.INSERTCOMMA)),a):(this.next(),a.setIndex(this.pEXPRESSION()),a.errors.length>0?a:","!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.INSERTCOMMA)),a):(this.next(),a.setValue(this.pEXPRESSION()),a.errors.length>0?a:";"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a)))},Eden.AST.prototype.pDELETE=function(){var a=new Eden.AST.Delete;return a.setDest(this.pLVALUE()),a.errors.length>0?a:","!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.DELETECOMMA)),a):(this.next(),a.setIndex(this.pEXPRESSION()),a.errors.length>0?a:";"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a))},Eden.AST.prototype.pAPPEND=function(){var a=new Eden.AST.Append;return a.setDest(this.pLVALUE()),a.errors.length>0?a:","!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.APPENDCOMMA)),a):(this.next(),a.setIndex(this.pEXPRESSION()),a.errors.length>0?a:";"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a))},Eden.AST.prototype.pSHIFT=function(){var a=new Eden.AST.Shift;return a.setDest(this.pLVALUE()), +a.errors.length>0?a:";"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a)},Eden.AST.prototype.pELIST=function(){var a=this.pEXPRESSION();if(a.errors.length>0)return[a];var b=this.pELIST_P();return b.unshift(a),b},Eden.AST.prototype.pELIST_P=function(){for(var a=[];","==this.token;){this.next();var b=this.pEXPRESSION();if(a.push(b),b.errors.length>0)return a}return a},Eden.AST.prototype.pOLIST=function(){if("OBSERVABLE"!=this.token)return[];var a=this.data.value;this.next();var b=this.pOLIST_P();return b.unshift(a),b},Eden.AST.prototype.pOLIST_P=function(){for(var a=[];","==this.token;){if(this.next(),"OBSERVABLE"!=this.token)return a.push("NONAME"),a;a.push(this.data.value),this.next()}return a},Eden.AST.prototype.pLVALUE_P=function(){for(var a=[];;){if("["!=this.token)break;this.next();var b=new Eden.AST.LValueComponent("index"),c=this.pEXPRESSION();if(b.index(c),a.push(b),c.errors.length>0&&b.errors.unshift(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP)),"literal"==b.indexexp.type&&"NUMBER"==b.indexexp.datatype&&b.indexexp.value<1&&b.error(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS)),"]"!=this.token)return b.error(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE)),a;this.next()}return a},Eden.AST.prototype.pLVALUE=function(){var a=new Eden.AST.LValue;if("*"==this.token)this.next(),a.setPrimary(this.pPRIMARY());else if("`"==this.token){if(this.next(),a.setExpression(this.pEXPRESSION()),a.errors.length>0)return a;if("`"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.BACKTICK)),a;this.next()}else{if("OBSERVABLE"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.LVALUE)),a;var b=this.data.value;if(this.next(),"{"==this.token){for(var c=new Eden.AST.Literal("STRING",b);"{"==this.token;){this.next();var d=this.pEXPRESSION();if(d.errors.length>0)return a.setExpression(d),a;if("}"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.BACKTICK)),a;this.next();var e=new Eden.AST.BinaryOp("//");if(e.left(c),e.setRight(d),c=e,"OBSERVABLE"==this.token){var e=new Eden.AST.BinaryOp("//");e.left(c),e.setRight(new Eden.AST.Literal("STRING",this.data.value)),c=e,this.next()}}a.setExpression(c)}else a.setObservable(b)}return a.setExtras(this.pLVALUE_P()),a},Eden.AST.prototype.pPRIMARY=function(){if("`"==this.token){this.next();var a=this.pEXPRESSION();if(a.errors.length>0){var b=new Eden.AST.Primary;return b.setBackticks(a),b}if("`"!=this.token){var b=new Eden.AST.Primary;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.BACKTICK)),b}this.next();var b=this.pPRIMARY_P();return b.errors.length>0?b:(b.setBackticks(a),b.setObservable("__BACKTICKS__"),b)}if("OBSERVABLE"==this.token){var b,c=this.data.value;if(this.next(),"{"==this.token){for(var d=new Eden.AST.Literal("STRING",c);"{"==this.token;){this.next();var a=this.pEXPRESSION();if(a.errors.length>0){var b=new Eden.AST.Primary;return b.setBackticks(a),b}if("}"!=this.token){var b=new Eden.AST.Primary;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.BACKTICK)),b}this.next();var e=new Eden.AST.BinaryOp("//");if(e.left(d),e.setRight(a),d=e,"OBSERVABLE"==this.token){var e=new Eden.AST.BinaryOp("//");e.left(d),e.setRight(new Eden.AST.Literal("STRING",this.data.value)),d=e,this.next()}}b=this.pPRIMARY_P(),b.setBackticks(d),b.setObservable("__BACKTICKS__")}else b=this.pPRIMARY_P(),b.setObservable(c);return b}var b=new Eden.AST.Primary;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.BADFACTOR)),b},Eden.AST.prototype.pPRIMARY_P=function(){if("["==this.token){this.next();var a=new Eden.AST.Index;if("]"==this.token){var b=new Eden.AST.Primary;return b.prepend(a),b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP)),b}var c=this.pEXPRESSION();if(c.errors.length>0){a.setExpression(c);var b=new Eden.AST.Primary;return b.prepend(a),b}if("literal"==c.type&&"NUMBER"==c.datatype&&c.value<1){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS));var b=new Eden.AST.Primary;return b.prepend(a),b}if("]"!=this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE));var b=new Eden.AST.Primary;return b.prepend(a),b}this.next();var b=this.pPRIMARY_PPP();return a.setExpression(c),b.prepend(a),b}if("("==this.token){this.next();var d=new Eden.AST.FunctionCall;if(")"==this.token){this.next();var b=this.pPRIMARY_PP();return b.prepend(d),b}var e=this.pELIST();if(d.setParams(e),d.errors.length>0){var b=new Eden.AST.Primary;return b.prepend(d),b}if(")"!=this.token){var b=new Eden.AST.Primary;return b.prepend(d),d.errors.length>0?b:(b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCALLEND)),b)}this.next();var b=this.pPRIMARY_PP();return b.errors.length>0?b:(b.prepend(d),b)}if("."==this.token){this.next();var f=this.pPRIMARY(),g=new Eden.AST.ScopePath;return g.setPrimary(f),g}return this.pPRIMARY_PPPP()},Eden.AST.prototype.pPRIMARY_PP=function(){if("["==this.token){this.next();var a=new Eden.AST.Index;if("]"==this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP));var b=new Eden.AST.Primary;return b.prepend(a),b}var c=this.pEXPRESSION();if(c.errors.length>0){var b=new Eden.AST.Primary;return a.setExpression(c),b.prepend(a),b}if("literal"==c.type&&"NUMBER"==c.datatype&&c.value<1){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS));var b=new Eden.AST.Primary;return b.prepend(a),b}if("]"!=this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE));var b=new Eden.AST.Primary;return b.prepend(a),b}this.next();var b=this.pPRIMARY_PP();return a.setExpression(c),b.prepend(a),b}if("("==this.token){this.next();var d=new Eden.AST.FunctionCall;if(")"==this.token){this.next();var b=this.pPRIMARY_PP();return b.prepend(d),b}var e=this.pELIST();if(d.setParams(e),")"!=this.token){var b=new Eden.AST.Primary;return b.prepend(d),d.errors.length>0?b:(b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCALLEND)),b)}this.next();var b=this.pPRIMARY_PP();return b.prepend(d),b}return this.pPRIMARY_PPPP()},Eden.AST.prototype.pPRIMARY_PPP=function(){if("["==this.token){this.next();var a=new Eden.AST.Index;if("]"==this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP));var b=new Eden.AST.Primary;return b.prepend(a),b}var c=this.pEXPRESSION();if(c.errors.length>0){var b=new Eden.AST.Primary;return a.setExpression(c),b.prepend(a),b}if("literal"==c.type&&"NUMBER"==c.datatype&&c.value<1){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS));var b=new Eden.AST.Primary;return b.prepend(a),b}if("]"!=this.token){a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE));var b=new Eden.AST.Primary;return b.prepend(a),b}this.next();var b=this.pPRIMARY_PP();return a.setExpression(c),b.prepend(a),b}if("("==this.token){this.next();var d=new Eden.AST.FunctionCall;if(")"==this.token){this.next();var b=this.pPRIMARY_PP();return b.prepend(d),b}var e=this.pELIST();if(d.setParams(e),")"!=this.token){var b=new Eden.AST.Primary;return b.prepend(d),d.errors.length>0?b:(b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCALLEND)),b)}this.next();var b=this.pPRIMARY_PP();return b.errors.length>0?b:(b.prepend(d),b)}if("."==this.token){this.next();var f=this.pPRIMARY();if(f.errors.length>0)return f;var g=new Eden.AST.ScopePath;return g.setPrimary(f),g}return this.pPRIMARY_PPPP()},Eden.AST.prototype.pPRIMARY_PPPP=function(){return new Eden.AST.Primary},Eden.AST.prototype.pACTION=function(){var a=new Eden.AST.Action,b=this.parent;if(this.parent=a,a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.DEPRECATED,"attempt to use 'when' instead of 'proc'"),"OBSERVABLE"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.PROCNAME)),this.parent=b,a;if(a.name=this.data.value,this.next(),":"==this.token){this.next();var c=this.pOLIST();if(0==c.length)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONNOWATCH)),this.parent=b,a;if("NONAME"==c[c.length-1])return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCOMMAS)),this.parent=b,a;a.triggers=c}return a.setBody(this.pFUNCBODY()),this.parent=b,a},Eden.AST.prototype.pSCOPE=function(){if("("==this.token){this.next();var a=this.pSCOPE_P();return")"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SCOPECLOSE)),a):(this.next(),a)}return this.pSCOPE_P()},Eden.AST.prototype.pSCOPEPATTERN=function(){var a=new Eden.AST.ScopePattern;if("OBSERVABLE"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SCOPENAME)),a;for(a.setObservable(this.data.value),this.next();;)if("["==this.token){this.next();var b=this.pEXPRESSION();if(a.addListIndex(b),b.errors.length>0)return a;if("]"!=this.token)return a.error(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE)),a;this.next()}else if("."!=this.token)break;return a},Eden.AST.prototype.pSCOPE_P=function(){var a=this.pSCOPEPATTERN(),b=!1;if(a.errors.length>0){var c=new Eden.AST.Scope;return c.addOverride(a,void 0,void 0,void 0,!1),c}if("is"!=this.token&&"="!=this.token&&"in"!=this.token){var c=new Eden.AST.Scope;return c.error(new Eden.SyntaxError(this,Eden.SyntaxError.SCOPEEQUALS)),c}"in"==this.token&&(b=!0),this.next();var d=this.pEXPRESSION();if(d.errors.length>0){var c=new Eden.AST.Scope;return c.errors.push.apply(c.errors,d.errors),c}var e=void 0;if(".."==this.token&&(this.next(),e=this.pEXPRESSION(),e.errors.length>0)){var c=new Eden.AST.Scope;return c.addOverride(a,d,e,void 0,!1),c}var f=void 0;if(".."==this.token&&(this.next(),f=this.pEXPRESSION(),f.errors.length>0)){var c=new Eden.AST.Scope;return c.addOverride(a,d,e,f,!1),c}var c=this.pSCOPE_PP();return c.addOverride(a,d,e,f,b),c},Eden.AST.prototype.pSCOPE_PP=function(){return","==this.token?(this.next(),this.pSCOPE_P()):new Eden.AST.Scope},Eden.AST.prototype.pNAMEDSCRIPT=function(){var a;if("OBSERVABLE"!=this.token){var b=new Eden.AST.Script;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONNAME)),b}if(a=this.data.value,this.next(),"is"==this.token){this.next();var c=new Eden.AST.Alias;return c.setSelector(this.pCODESELECTOR()),c.setName(a),";"!=this.token?(c.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),c):(this.next(),c)}if("{"!=this.token){var b=new Eden.AST.Script;return b.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONOPEN)),b}this.next();var b=this.pSCRIPT();return b.errors.length>0?b:(b.setName(this,a),"}"!=this.token?(b.error(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),b):(this.next(),this.scripts[a]=b,b))},Eden.AST.prototype.pSCRIPT=function(){var a=new Eden.AST.Script;a.parent=this.parent;var b=this.parent;this.parent=a;var c=new Eden.AST.DummyStatement;for(c.setSource(this.lastposition,this.stream.prevposition,this.stream.code.substring(this.lastposition,this.stream.prevposition)),c.numlines=c.source.match(/\n/g),null===c.numlines?c.numlines=0:c.numlines=c.numlines.length,a.append(c);"EOF"!=this.token;){var d=this.pSTATEMENT();if(void 0!==d){if(d.errors.length>0){a.appendChild(d);break}var e=d.end;a.appendChild(d);var f=this.stream.code.substring(e,this.stream.prevposition);if(f.length>0){var c=new Eden.AST.DummyStatement;c.setSource(e,this.stream.prevposition,f),c.numlines=c.source.match(/\n/g),null===c.numlines?c.numlines=0:c.numlines=c.numlines.length,a.appendChild(c)}}else{if("}"!=this.token&&";"!=this.token&&a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.STATEMENT)),";"!=this.token)break;this.next()}}return this.parent=b,a},Eden.AST.prototype.pSCRIPTEXPR=function(){var a=new Eden.AST.ScriptExpr;a.parent=this.parent;for(this.parent;"EOF"!=this.token;){var b=this.pSTATEXPR();if(void 0!==b){if(a.append(b),b.errors.length>0)break}else{if("}"!=this.token&&";"!=this.token&&a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.STATEMENT)),";"!=this.token)break;this.next()}}return a},Eden.AST.prototype.pAGENTPATH=function(){if("OBSERVABLE"!=this.token&&void 0===Language.keywords[this.token])return"_ERROR_";var a=this.data.value;for(this.next();"/"==this.token;){if(this.next(),"OBSERVABLE"!=this.token&&void 0===Language.keywords[this.token])return"_ERROR_";a+="/"+this.data.value,this.next()}return a},Eden.AST.prototype.pCODESELECTOR=function(){var a=void 0;if("OBSERVABLE"==this.token||Language.keywords[this.token])a=new Eden.AST.Literal("STRING",this.data.value),this.next();else if(":"==this.token||"."==this.token){var b=":"==this.token;if(this.next(),"OBSERVABLE"==this.token){if(!(!b&&Eden.Selectors.PropertyNode.attributes[this.data.value]||b&&Eden.Selectors.PropertyNode.pseudo[this.data.value]))return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTORATTRIB)),a;a=new Eden.AST.Literal("STRING",(b?":":".")+this.data.value),this.next()}else if("NUMBER"==this.token)a=new Eden.AST.Literal("STRING",(b?":":".")+this.data.value),this.next();else if("{"==this.token)a=new Eden.AST.Literal("STRING",b?":":".");else{if("("!=this.token)return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTORATTRIB)),a;var c=this.stream.position;for(this.next();this.stream.valid()&&")"!=this.token;)this.next();var d=this.stream.prevposition,e=":("+this.stream.code.substring(c,d).replace(/[\r\n]*/g,"")+")";a=new Eden.AST.Literal("STRING",e),this.next()}}else if("@"==this.token){if(this.next(),"OBSERVABLE"!=this.token)return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTOROPTION)),a;if(!Eden.Selectors.allowedOptions[this.data.value])return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTOROPTION)),a;a=new Eden.AST.Literal("STRING","@"+this.data.value+" "),this.next()}else if("#"==this.token)if(this.next(),"OBSERVABLE"==this.token)a=new Eden.AST.Literal("STRING","#"+this.data.value),this.next();else{if("{"!=this.token)return a=new Eden.AST.Literal("STRING",""),a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTORTAG)),a;a=new Eden.AST.Literal("STRING","#")}else if("{"==this.token){if(this.next(),a=this.pEXPRESSION(),"}"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SELECTORBTICK)),a;this.next()}else if(">"==this.token)a=new Eden.AST.Literal("STRING"," > "),this.next();else if(">>"==this.token)a=new Eden.AST.Literal("STRING"," >> "),this.next();else if("<"==this.token)a=new Eden.AST.Literal("STRING"," < "),this.next();else if(","==this.token)a=new Eden.AST.Literal("STRING",","),this.next();else if("<<"==this.token)a=new Eden.AST.Literal("STRING"," << "),this.next();else if("("==this.token){var c=this.stream.position;for(this.next();this.stream.valid()&&")"!=this.token;)this.next();var d=this.stream.prevposition,e="("+this.stream.code.substring(c,d).replace(/[\r\n]*/g,"")+")";a=new Eden.AST.Literal("STRING",e),this.next()}else{if(")"==this.token)return;"*"==this.token&&(a=new Eden.AST.Literal("STRING","*"),this.next())}if(a){var f=this.pCODESELECTOR();if(void 0===f)return a;if(f.errors.length>0)return f;if("literal"==a.type&&"literal"==f.type)a.value+=f.value;else{var g=new Eden.AST.BinaryOp("//");g.left(a),g.setRight(f),a=g}}return a},Eden.AST.prototype.pSTATEMENT_PP=function(a){if("is"==this.token){this.next();var b=new Eden.AST.Definition,c=this.parent;this.parent=b;var d=this.pEXPRESSION();return b.setExpression(d),this.parent=c,b}if("in"==this.token){if(this.next(),!a){var e=new Eden.AST.Range;return e.error(new Eden.SyntaxError(this,Eden.SyntaxError.RANGEBANNED)),e}var e=new Eden.AST.Range(this.pEXPRESSION());return".."==this.token&&(this.next(),e.setSecond(this.pEXPRESSION())),e}if("="==this.token)return this.next(),new Eden.AST.Assignment(this.pEXPRESSION());if("+="==this.token)return this.next(),new Eden.AST.Modify("+=",this.pEXPRESSION());if("-="==this.token)return this.next(),new Eden.AST.Modify("-=",this.pEXPRESSION());if("/="==this.token)return this.next(),new Eden.AST.Modify("/=",this.pEXPRESSION());if("*="==this.token)return this.next(),new Eden.AST.Modify("*=",this.pEXPRESSION());if("~>"==this.token){this.next();var f=new Eden.AST.Subscribers;return"["!=this.token?(f.error(new Eden.SyntaxError(this,Eden.SyntaxError.SUBSCRIBEOPEN)),f):(this.next(),f.setList(this.pOLIST()),f.errors.length>0?f:"]"!=this.token?(f.error(new Eden.SyntaxError(this,Eden.SyntaxError.SUBSCRIBECLOSE)),f):(this.next(),f))}if("++"==this.token)return this.next(),new Eden.AST.Modify("++",(void 0));if("--"==this.token)return this.next(),new Eden.AST.Modify("--",(void 0));if("("==this.token){var g=new Eden.AST.FunctionCall;if(this.next(),")"!=this.token){if(g.setParams(this.pELIST()),g.errors.length>0)return g;if(")"!=this.token)return g.error(new Eden.SyntaxError(this,Eden.SyntaxError.FUNCCLOSE)),g}return this.next(),g}var h=[];h.push(new Eden.SyntaxError(this,Eden.SyntaxError.DEFINITION));var i=new Eden.AST.Assignment((void 0));return i.errors.unshift(h[0]),i},Eden.AST.prototype.pSTATEMENT_P=function(a){var b=this.pLVALUE();if(b.errors.length>0)return b;var c=this.pSTATEMENT_PP(a);return c.left(b),c.errors.length>0?c:c},Eden.AST.prototype.pSTATEMENT=function(){var a=this.stream.prevposition,b=this.stream.line-1,c=-1,d=void 0,e=-1,f=this.lastDoxyComment.length>0?this.lastDoxyComment.pop():void 0;switch(0==this.lastDoxyComment.length&&this.parentDoxy&&this.lastDoxyComment.push(this.parentDoxy),this.token){case"proc":this.next(),d=this.pACTION();break;case"func":this.next(),d=this.pFUNCTION();break;case"when":this.next(),d=this.pWHEN();break;case"action":this.next(),d=this.pNAMEDSCRIPT();break;case"for":this.next(),d=this.pFOR();break;case"while":this.next(),d=this.pWHILE();break;case"do":this.next(),d=this.pDO();break;case"wait":this.next(),d=this.pWAIT();break;case"switch":this.next(),d=this.pSWITCH();break;case"case":this.next(),d=this.pCASE();break;case"insert":this.next(),d=this.pINSERT();break;case"delete":this.next(),d=this.pDELETE();break;case"append":this.next(),d=this.pAPPEND();break;case"shift":this.next(),d=this.pSHIFT();break;case"require":this.next(),d=this.pREQUIRE();break;case"after":this.next(),d=this.pAFTER();break;case"import":this.next(),d=this.pIMPORT();break;case"local":case"auto":d=this.pLOCALS();break;case"default":this.next();var g=new Eden.AST.Default;":"!=this.token?g.error(new Eden.SyntaxError(this,Eden.SyntaxError.DEFAULTCOLON)):this.next(),d=g;break;case"if":this.next(),d=this.pIF();break;case"#":var h=this.stream.position+1,i=this.stream.line,j=33==this.stream.peek();do this.stream.skipLine(),this.stream.valid()||this.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.NEWLINE)),this.stream.skip(),this.stream.line++;while(35==this.stream.peek()&&35!=this.stream.peek2());if(j){var k=new Eden.AST.DoxyComment(this.stream.code.substring(h,this.stream.position-1).trim(),i,this.stream.line);k.parent=this.parentDoxy,k.content.endsWith("@{")?this.parentDoxy=k:k.content.startsWith("@}")&&this.parentDoxy&&(this.parentDoxy=this.parentDoxy.parent),!this.lastStatement||void 0!==this.lastStatement.doxyComment||this.lastStatEndline!=i-1&&this.lastStatEndline!=i?this.lastDoxyComment.push(k):this.lastStatement.setDoxyComment(k)}this.next(),d=new Eden.AST.DummyStatement;break;case"##":d=this.pSECTION(),this.lastDoxyComment.length>0&&this.lastline==this.lastDoxyComment[0].startline-1&&d.setDoxyComment(this.lastDoxyComment.shift());break;case"return":this.next();var l=new Eden.AST.Return;if(";"==this.token){this.next(),d=l;break}if(l.setResult(this.pEXPRESSION()),l.errors.length>0){d=l;break}";"!=this.token?l.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),d=l;break;case"continue":this.next();var m=new Eden.AST.Continue;if(m.errors.length>0){d=m;break}";"!=this.token?m.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),d=m;break;case"break":this.next();var n=new Eden.AST.Break;if(n.errors.length>0){d=n;break}";"!=this.token?n.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),d=n;break;case"{":this.next();var o=this.pSCRIPT();if("}"!=this.token){o.error(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),d=o;break}this.next(),d=o;break;case"JAVASCRIPT":b=this.data.line-1;var p=this.data.value;this.next(),d=new Eden.AST.Literal("JAVASCRIPT",p);break;case"?":this.next(),d=this.pQUERY(),";"!=this.token?d.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next();break;case"`":case"*":case"OBSERVABLE":var q=this.pLVALUE();if(q.errors.length>0){d=new Eden.AST.DummyStatement,d.lvalue=q,d.errors=q.errors;break}var r=this.pSTATEMENT_PP();if(r.left(q),r.errors.length>0){d=r;break}";"!=this.token?r.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),void 0===this.definitions[q.name]&&(this.definitions[q.name]=[]),this.definitions[q.name].push(r),d=r;break;default:return}return e=this.lastposition,c=this.lastline,d.parent=this.parent,void 0===d.doxyComment&&d.setDoxyComment(f),d.stamp=this.stamp,d.numlines=c-b-1,d.setSource(a,e,this.stream.code.substring(a,e)),"dummy"!=d.type&&(this.lastStatement=d,this.lastStatEndline=c),d},Eden.AST.prototype.pSTATEXPR=function(){var a=(this.stream.prevposition,void 0),b=this.lastDoxyComment;switch(this.lastDoxyComment=this.parentDoxy,this.token){case"proc":case"func":case"when":case"wait":case"do":case"require":case"after":case"import":case"action":a=new Eden.AST.DummyStatement,a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.UNKNOWN));break;case"for":this.next(),a=this.pFOR();break;case"while":this.next(),a=this.pWHILE();break;case"switch":this.next(),a=this.pSWITCH();break;case"case":this.next(),a=this.pCASE();break;case"insert":this.next(),a=this.pINSERT();break;case"delete":this.next(),a=this.pDELETE();break;case"append":this.next(),a=this.pAPPEND();break;case"shift":this.next(),a=this.pSHIFT();break;case"para":case"oracle":a=this.pPARAMS();break;case"local":case"auto":a=this.pLOCALS();break;case"default":this.next();var c=new Eden.AST.Default;":"!=this.token?c.error(new Eden.SyntaxError(this,Eden.SyntaxError.DEFAULTCOLON)):this.next(),a=c;break;case"if":this.next(),a=this.pIF();break;case"return":this.next();var d=new Eden.AST.Return;if(";"==this.token){this.next(),a=d;break}if(d.setResult(this.pEXPRESSION()),d.errors.length>0){a=d;break}";"!=this.token?d.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),a=d;break;case"continue":this.next();var e=new Eden.AST.Continue;if(e.errors.length>0){a=e;break}";"!=this.token?e.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),a=e;break;case"break":this.next();var f=new Eden.AST.Break;if(f.errors.length>0){a=f;break}";"!=this.token?f.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):this.next(),a=f;break;case"{":this.next();var g=this.pSCRIPT();if("}"!=this.token){g.error(new Eden.SyntaxError(this,Eden.SyntaxError.ACTIONCLOSE)),endline=this.stream.line,a=g;break}endline=this.stream.line,this.next(),a=g;break;case"JAVASCRIPT":curline=this.data.line-1;var h=this.data.value;this.next(),a=new Eden.AST.Literal("JAVASCRIPT",h);break;case"`":case"*":case"OBSERVABLE":var i=this.pLVALUE();if(i.errors.length>0){a=new Eden.AST.DummyStatement,a.lvalue=i,a.errors=i.errors;break}var j=this.pSTATEMENT_PP();if(j.left(i),j.errors.length>0){a=j,endline=this.stream.line;break}";"!=this.token?j.error(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)):(end=this.stream.position,endline=this.stream.line,this.next()),void 0===this.definitions[i.name]&&(this.definitions[i.name]=[]),this.definitions[i.name].push(j),a=j;break;default:return}return a.parent=this.parent,a.doxyComment=b,a},Eden.AST.prototype.pSWITCH=function(){var a=new Eden.AST.Switch,b=this.parent;return this.parent=a,"("!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SWITCHOPEN)),this.parent=b,a):(this.next(),a.setExpression(this.pEXPRESSION()),a.errors.length>0?(this.parent=b,a):")"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SWITCHCLOSE)),this.parent=b,a):(this.next(),"{"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.SWITCHSCRIPT)),this.parent=b,a):(a.setStatement(this.pSTATEMENT()),this.parent=b,a)))},Eden.AST.prototype.pCASE=function(){var a=new Eden.AST.Case;return"STRING"!=this.token&&"NUMBER"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.CASELITERAL)),a):(a.setLiteral(this.token,this.data.value),this.next(),":"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.CASECOLON)),a):(this.next(),a))},Eden.AST.prototype.pTERM=function(){var a=this.pTERM_A(),b=this.pEXPRESSION_PPPPPP();return b?(b.left(a),b):a},Eden.AST.prototype.pTERM_A=function(){for(var a=this.pTERM_P();"<"==this.token||"<="==this.token||">"==this.token||">="==this.token||"=="==this.token||"!="==this.token;){var b=new Eden.AST.BinaryOp(this.token);this.next(),b.left(a),b.setRight(this.pTERM_P()),a=b}return a},Eden.AST.prototype.pTERM_P=function(){for(var a=this.pTERM_PP();"+"==this.token||"-"==this.token||"//"==this.token;){var b=new Eden.AST.BinaryOp(this.token);this.next(),b.left(a),b.setRight(this.pTERM_PP()),a=b}return a},Eden.AST.prototype.pTERM_PP=function(){for(var a=this.pTERM_PPP();"*"==this.token||"/"==this.token||"%"==this.token||"^"==this.token;){var b=new Eden.AST.BinaryOp(this.token);this.next(),b.left(a),b.setRight(this.pTERM_PPP()),a=b}return a},Eden.AST.prototype.pTERM_PPP=function(){var a=this.pFACTOR(),b=this.pEXPRESSION_PPPPP();return b?(b.left(a),b):a},Eden.AST.prototype.pWAIT=function(){var a=new Eden.AST.Wait;if(";"==this.token)return this.next(),a;var b=this.pEXPRESSION();return a.setDelay(b),";"!=this.token?(a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a):(this.next(),a)},Eden.AST.prototype.pWHEN=function(){var a=new Eden.AST.When,b=this.parent;if(this.parent=a,"("!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.WHENOPEN)),this.parent=b,a;if(this.next(),a.setExpression(this.pEXPRESSION()),a.errors.length>0)return this.parent=b,a;if(")"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.WHENCLOSE)),this.parent=b,a;if(this.next(),a.setStatement(this.pSTATEMENT()),a.errors.length>0)return this.parent=b,a;if(void 0===a.statement)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.WHENNOSTATEMENT)),a.active=!0,this.parent=b,a;if("with"==this.token||"::"==this.token){this.next();var c=this.pSCOPE();if(a.setScope(c),c.errors.length>0)return a;if(";"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.SEMICOLON)),a;this.next()}return a.compile(this),this.whens.push(a),this.parent=b,a},Eden.AST.prototype.pWHILE=function(){var a=new Eden.AST.While,b=this.parent;return this.parent=a,a.warning=new Eden.SyntaxWarning(this,a,Eden.SyntaxWarning.USEOFWHILE),"("!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.WHILEOPEN)),this.parent=b,a):(this.next(),a.setCondition(this.pEXPRESSION()),a.errors.length>0?(this.parent=b,a):")"!=this.token?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.WHILECLOSE)),this.parent=b,a):(this.next(),a.setStatement(this.pSTATEMENT()),void 0===a.statement?(a.error(new Eden.SyntaxError(this,Eden.SyntaxError.WHILENOSTATEMENT)),this.parent=b,a):(this.parent=b,a)))},Eden.AST.prototype.pQUERY=function(){var a=new Eden.AST.Query,b=[];if("("!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYOPEN)),a;if(this.next(),a.setSelector(this.pCODESELECTOR()),")"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYCLOSE)),a;if(this.next(),"["!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYSELECTOPEN)),a;for(this.next();this.stream.valid()&&"]"!=this.token&&(b.push(this.data.value),this.next(),"]"!=this.token);){if(","!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYSELECTCOMMA)),a;this.next()}if("]"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.QUERYSELECTCLOSE)),a;if(this.next(),"="==this.token||"+="==this.token||"//="==this.token){var c=this.token;this.next();var d=this.pEXPRESSION();a.setModify(d,c)}return 0==b.length&&b.push("id"),a.setResultTypes(b),a},Eden.AST.prototype.pINDEXED=function(){for(var a=new Eden.AST.Indexed;this.stream.valid()&&"["==this.token;){this.next();var b=new Eden.AST.Index;if("]"==this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXEXP)),a;var c=this.pEXPRESSION();if(c.errors.length>0)return b.setExpression(c),a.addIndex(b),a;if("literal"==c.type&&"NUMBER"==c.datatype&&c.value<1)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.OUTOFBOUNDS)),a;if("]"!=this.token)return a.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.LISTINDEXCLOSE)),a;this.next(),b.setExpression(c),a.addIndex(b)}return a},Eden.AST.prototype.pSECTION=function(){for(var a=1;35==this.stream.peek();)a++,this.stream.skip();var b=this.stream.readLine().trim();return this.stream.valid()?(this.stream.position--,this.stream.line--):this.errors.push(new Eden.SyntaxError(this,Eden.SyntaxError.NEWLINE)),this.next(),stat=new Eden.AST.Section,stat.setName(b),stat.depth=a,stat},Eden.Project=function(a,b,c){this.title=b,this.name=b.replace(/[^a-zA-Z0-9]/g,""),this.author=void 0,this.authorid=-1,this.tags=b.toLowerCase().split(" "),this.src=c,this.ast=new Eden.AST(c,(void 0),this),this.id=a,this.vid=void 0,this.parentid=void 0,this.triggers={},this.thumb=void 0,this.desc=void 0,this.readPassword=void 0,this.ast&&0==this.ast.script.errors.length,eden.root.lookup("jseden_project_title").assign(b,eden.root.scope,Symbol.localJSAgent),eden.root.lookup("jseden_project_name").assign(this.name,eden.root.scope,Symbol.localJSAgent)},Eden.Project.listenTo=listenTo,Eden.Project.emit=emit,Eden.Project.unListen=unListen,Eden.Project.listeners={},Eden.Project.init=function(){var a=eden.root.lookup("jseden_project_title");a.addJSObserver("project",function(a,b){if(a.origin!==eden.project){if(void 0===eden.project)return;eden.project.title=b,void 0===this.id&&(Eden.Index.remove(eden.project.ast.script),eden.project.name=b.replace(/[^a-zA-Z0-9]/g,""),eden.project.ast.script.name=eden.project.name,console.log("REINDEX PROJECT"),Eden.Index.update(eden.project.ast.script)),eden.project.ast.script.doxyComment=eden.project.ast.doxyFromOrigin(),Eden.Fragment.emit("aststatus",[eden.project.ast.script])}}),$.get("resources/projects.db.json",function(a){Eden.Project.local=a},"json"),eden.root.addGlobal(function(a,b){if(void 0!==eden.project){var c=eden.project.triggers[a.name];if(c)for(var d=0;d'+h+"",null!==g&&(e+=g.length)}else if(2==c[f][1]){var h=EdenUI.Highlight.html(c[f][1]);d+="line:"+(e+1)+' - '+h+"",null!==g&&(e-=g.length)}}else null!==g&&(e+=g.length)}return d},Eden.Project.prototype.save=function(a,b){Eden.DB.save(this,a,b)},Eden.Project.restore=function(){if(window.localStorage){var a=window.localStorage.getItem("last_project"),b=window.localStorage.getItem("last_id");"undefined"==b&&(b=void 0);var c=window.localStorage.getItem("last_vid");"undefined"==c&&(c=void 0);var d=window.localStorage.getItem("last_author");"undefined"==d&&(d=void 0);var e=window.localStorage.getItem("last_authorid"),f=window.localStorage.getItem("last_name"),g=window.localStorage.getItem("last_thumb");"undefined"==g&&(g=void 0);var h=window.localStorage.getItem("last_desc"),i=window.localStorage.getItem("last_title");a&&""!=a&&(eden.root.lookup("jseden_project_mode").assign("restore",eden.root.scope,Symbol.defaultAgent),eden.project=new Eden.Project(b,i,a),eden.project.vid=c,eden.project.author=d,eden.project.name=f,eden.project.authorid=e,eden.project.thumb=g,eden.project.desc=h,eden.project.start())}},Eden.Project.prototype.restore=function(){},Eden.Project.prototype.localSave=function(){window.localStorage&&(window.localStorage.setItem("last_project",this.generate()),window.localStorage.setItem("last_id",this.id),window.localStorage.setItem("last_vid",this.vid),window.localStorage.setItem("last_author",this.author),window.localStorage.setItem("last_authorid",this.authorid),window.localStorage.setItem("last_name",this.name),window.localStorage.setItem("last_title",this.title),window.localStorage.setItem("last_thumb",this.thumb),window.localStorage.setItem("last_desc",this.desc))},Eden.Project.prototype.patch=function(a,b){},Eden.Project.prototype.snapshot=function(){},Eden.Project.prototype.addAction=function(a){var b=Eden.AST.parseStatement("action "+a+" {}");return this.ast.script.appendChild(b),b.addIndex(),b},Eden.Project.prototype.generate=function(){return this.ast.getSource()},Eden.Project.prototype.getDescription=function(){return void 0===this.desc&&(this.desc="# "+this.title+"\nEnter a project description here,\nand some hashtags as below.\n\nTags: #"+this.tags.join(" #")),this.desc},Eden.Project.prototype.setDescription=function(a){this.desc=a;var b=new Eden.AST.DoxyComment(a,0,0);this.tags=b.getHashTags().map(function(a){return a.substring(1)})},Eden.Project.prototype.addTrigger=function(a,b,c){console.log("Add When Trigger",b),void 0===this.triggers[b]&&(this.triggers[b]=[]),this.triggers[b].push({statement:a,scope:c})},Eden.Project.prototype.registerAgent=function(a){console.log("REGISTER WHEN",a);for(var b in a.dependencies)void 0===this.triggers[b]&&(this.triggers[b]=[]),this.triggers[b].push({statement:a,scope:eden.root.scope})},Eden.Project.prototype.removeAgent=function(a){console.log("REMOVE WHEN",a);for(var b in a.dependencies){var c=this.triggers[b];if(c)for(var d=0;d1){for(var d="",e=0;e0||b.remote;var g=b.originast.doxyComment;if(g){b.doxy=g;var h=g.getControls();h["@title"]&&(b.title=h["@title"][0])}else b.doxy=void 0;Eden.Fragment.emit("changed",[b]),b.locked&&Eden.Fragment.emit("locked",[b])}else console.log("Make scratch fragment"),b.locked=!1,b.remote=!1,b.ast=new Eden.AST(b.source,(void 0),b,{noindex:!0}),b.originast=b.ast.script,b.name="*Scratch*",b.title=b.name,b.scratch=!0,Eden.Fragment.emit("changed",[b]);b.lock(),b.snapshot=b.source,a&&a()})},Eden.Fragment.prototype.getSource=function(){return this.source?this.source:""},Eden.Fragment.prototype.makeReal=function(a){if(this.scratch){this.name=a,this.title=a,this.originast=eden.project.addAction(a),this.selector=Eden.Selectors.getID(this.originast),this.scratch=!1,this.remote=!1,this.setSource(this.source);for(var b=this.originast;b&&b.parent;)b=b.parent;this.origin=b.base.origin,this.lock()}},Eden.Fragment.prototype.setSourceInitial=function(a){this.source=a,this.snapshot=a,this.ast=new Eden.AST(a,(void 0),this)},Eden.Fragment.AUTOSAVE_INTERVAL=500,Eden.Fragment.prototype.undo=function(){if(!(this.index<0)&&0!=this.history.length){var a=this.history[this.index];this.index--;var b;if(this.index>=0&&this.history[this.index].snapshot)b=this.history[this.index].snapshot;else{var c=new diff_match_patch,d=c.patch_fromText(a.undo),e=c.patch_apply(d,this.snapshot);b=e[0]}this.snapshot=b,this.setSource(b)}},Eden.Fragment.prototype.canUndo=function(){return this.history.length>0&&this.index>=0},Eden.Fragment.prototype.canRedo=function(){return this.index=this.history.length-1)){this.index++;var a,b=this.history[this.index];if(b.snapshot)a=b.snapshot;else{var c=new diff_match_patch,d=c.patch_fromText(b.redo),e=c.patch_apply(d,this.snapshot);a=e[0]}this.snapshot=a,this.setSource(a)}},Eden.Fragment.prototype.addHistory=function(a,b){this.history.push({time:Date.now()/1e3|0,redo:a,undo:b}),this.index=this.history.length-1},Eden.Fragment.prototype.autoSave=function(){if(!(void 0===this.ast||this.ast.script.errors.length>0)){if(this.originast){var a=this.originast.parent;for(this.originast.patchScript(this.ast);a;)Eden.Fragment.emit("patch",[this,a]),a=a.parent}Eden.Fragment.emit("changed",[this])}},Eden.Fragment.prototype.diff=function(){if(this.origin&&this.origin.ast&&this.originast.end>0){var a=this.origin.ast.stream.code.substring(this.originast.start,this.originast.end),b=this.originast.prefix.length,c=this.originast.postfix.length;return a=a.substring(b,a.length-c),DiffUtil.diff(a,this.source)}},Eden.Fragment.prototype.setSource=function(a){if(!this.locked){var b=this;if(this.source=a,this.edited=!0,this.ast=new Eden.AST(a,(void 0),this,{noindex:!0}),0==this.ast.errors.length){if(this.originast){var c=this.originast.parent;for(this.originast.patchInner(this.ast.script),Eden.Fragment.emit("patch",[this,this.originast]);c;)Eden.Fragment.emit("patch",[this,c]),c=c.parent}Eden.Fragment.emit("status",[this]),eden.root.lookup("jseden_fragment_changed").assign(b.selector,eden.root.scope,Symbol.localJSAgent)}else Eden.Fragment.emit("errored",[this])}},Eden.Fragment.prototype.lock=function(){if(this.originast)for(var a=this.originast.parent;a;)a.lock++,Eden.Fragment.emit("lock",[this,a]),a=a.parent},Eden.Fragment.prototype.unlock=function(){if(this.originast)for(var a=this.originast.parent;a;)a.lock--,0==a.lock&&Eden.Fragment.emit("unlock",[this,a]),a=a.parent},Eden.Fragment.prototype.getTitle=function(){return this.originast&&this.originast.name?this.originast.name:this.name},Eden.Query={},Eden.Query.sortByCount=sortByCount,Eden.Query.reduceByCount=reduceByCount,Eden.Query.negativeFilter=negativeFilter,Eden.Query.search=function(a,b){var c=a.split(/[ ]+/),d=!1,e=0,f=c.length,g=!0,h=!0,i=!1,j=!0,k=!0,l=!0,m=!0,n={views:[],symbols:[],whens:[],projects:[],scripts:[],statements:[]};if(c.length>0&&":"==c[0].charAt(c[0].length-1)){if(e=1,d=!0,"select:"==c[0]){var o=a.substring(c[0].length).trim();return n.all=Eden.Selectors.query(o,"source"),void 0===n.all&&(n.all=[]),b&&b(n),b&&o.length>=3&&(Eden.Query.dbseltimeout&&clearTimeout(Eden.Query.dbseltimeout),Eden.Query.dbseltimeout=setTimeout(function(){Eden.Query.dbseltimeout=void 0,Eden.DB.searchSelector(o,"source",function(a){n.all.push.apply(n.all,a),b(n)})},1e3)),n}switch(c[0]){case"procs:":case"whens:":case"agents:":h=!0,g=!1,i=!1,j=!1,doremovescripts=!1,l=!0,m=!1;break;case"scripts:":h=!1,g=!1,j=!0,k=!0,i=!1,l=!1,m=!1}}for(f-=e;e2?!function(a){Eden.Query.dbtimeout&&clearTimeout(Eden.Query.dbtimeout),Eden.Query.dbtimeout=setTimeout(function(){Eden.Query.dbtimeout=void 0,Eden.DB.search(a,function(a){n.scripts.push.apply(n.scripts,a),n.scripts=reduceByCount(n.scripts,f),n.scripts=sortByLoaded(n.scripts),Eden.Query.mergeResults(n),b&&b(n)})},500)}(c[e]):j&&n.scripts.push.apply(n.scripts,Eden.Query.searchScripts(q))}else f--;return n.symbols=reduceByCount(n.symbols,f),Eden.Query.mergeResults(n),b&&b(n),n},Eden.Query.mergeResults=function(a){function b(d,e){c=0;for(var f=e;f=d);f++)c++,a.all.push("/"+a.symbols[f]);c=0;for(var f=e;f=d);f++)c++,a.all.push(a.whens[f]);c=0;for(var f=e;f=d-1);f++)c++,a.all.push("*script"+a.scripts[f]);c=0;for(var f=e;f=d);f++)c++,a.all.push(a.statements[f]);(a.symbols.length>e+d||a.whens.length>e+d||a.scripts.length>e+d)&&b(2,e+d)}a.all=[];var c=0;b(3,0)},Eden.Query.searchViews=function(a){},Eden.Query.searchSymbols=function(a,b){var c=[];for(var d in eden.root.symbols){var e=eden.root.symbols[d];if(a.test(d))e.last_modified_by.internal||"_"==d.charAt(0)||c.push(d);else if(b&&eden.dictionary[d]){var f=eden.dictionary[d].getHashTags();if(f)for(var g=0;g').html("").dialog({title:"Peer Connections",width:200,height:300,minHeight:120,minWidth:100})}this.connections={},this.id=id,this.master=master;var me=this;this.roles={},this.enabled=!1,this.loading=!1,this.config={control:!0,share:!1,observe:!1,logging:!1},this.callbacks={},this.callbackid=0,this.capturepatch=!1,void 0===eden.root.lookup("jseden_p2p_newconnections").value()&&eden.root.lookup("jseden_p2p_newconnections").assign([],eden.root.scope,Symbol.defaultAgent),void 0===eden.root.lookup("jseden_p2p_newdisconnections").value()&&eden.root.lookup("jseden_p2p_newdisconnections").assign([],eden.root.scope,Symbol.defaultAgent),void 0===eden.root.lookup("jseden_p2p_errors").value()&&eden.root.lookup("jseden_p2p_errors").assign([],eden.root.scope,Symbol.defaultAgent),Eden.Selectors.execute("lib > p2p"),Eden.DB.listenTo("login",this,init),Eden.DB.isLoggedIn()&&init(Eden.DB.username);var capInSym=eden.root.lookup("jseden_p2p_captureinput");capInSym.addJSObserver("p2p",function(a,b){b?(Symbol.hciAgent.local=!1,Symbol.localJSAgent.local=!1):(Symbol.hciAgent.local=!0,Symbol.localJSAgent.local=!0)});var capEdSym=eden.root.lookup("jseden_p2p_captureedits");capEdSym.addJSObserver("p2p",function(a,b){me.capturepatch=b}),edenUI.views.Peers={dialog:createDialog,title:"Connections",category:edenUI.viewCategories.environment},edenUI.menu.updateViewsMenu()},Eden.Peer.listeners={},Eden.Peer.emit=emit,Eden.Peer.listenTo=listenTo,Eden.Peer.prototype.broadcast=function(a){if(!this.loading){a=JSON.stringify(a);for(var b in this.connections){var c=this.connections[b];c.share&&c.connection.send(a)}}},Eden.Peer.prototype.broadcastExcept=function(a,b){if(!this.loading){b=JSON.stringify(b);for(var c in this.connections)if(c!=a){var d=this.connections[c];d.share&&d.connection.send(b)}}},Eden.Peer.prototype.authoriseWhen=function(a){if(this.enabled){if(a.doxyComment){var b=a.doxyComment.getControls()["@role"];if(b){for(var c=0;c0){var f=e.getSelection().getRangeAt(0),g=f.cloneRange();g.selectNodeContents(a),g.setEnd(f.endContainer,f.endOffset),c=g.toString().length}}else if((b=d.selection)&&"Control"!=b.type){var h=b.createRange(),i=d.body.createTextRange();i.moveToElementText(a),i.setEndPoint("EndToEnd",h),c=i.text.length}return c}function getStartCaretCharacterOffsetWithin(a){var b,c=0,d=a.ownerDocument||a.document,e=d.defaultView||d.parentWindow;if("undefined"!=typeof e.getSelection){if(b=e.getSelection(),b.rangeCount>0){var f=e.getSelection().getRangeAt(0),g=f.cloneRange();g.selectNodeContents(a),g.setEnd(f.startContainer,f.startOffset),c=g.toString().length}}else if((b=d.selection)&&"Control"!=b.type){var h=b.createRange(),i=d.body.createTextRange();i.moveToElementText(a),i.setEndPoint("EndToEnd",h),c=i.text.length}return c}function get_time_diff(a){var b=1e3*a,c=Date.now(),d=new Date,e=6e4*d.getTimezoneOffset();if(b-=e,isNaN(b))return"";if(b5)return new Date(b).toDateString();var i="";if(g>0)i+=g,i+=g>1?" days ago":" day ago";else if(h.getUTCHours()>0){var j=h.getUTCHours();i+=j,i+=j>1?" hours ago":" hour ago"}else{var k=h.getUTCMinutes();if(k>0)i+=k,i+=k>1?" minutes ago":" minute ago";else{var l=h.getUTCSeconds();i+=l,i+=" seconds ago"}}return i}function changeClassString(a,b,c){var d=a.split(" "),e=d.indexOf(b);if(e==-1){if(c)return d.push(b),d.join(" ")}else if(!c)return d.splice(e,1),d.join(" ");return a}function changeClass(a,b,c){if(a){var d=changeClassString(a.className,b,c);d!=a.className&&(a.className=d)}}function makeCurlyBrace(a,b,c,d,e,f){var g=a-c,h=b-d,i=Math.sqrt(g*g+h*h);g/=i,h/=i;var j=a+f*e*h,k=b-f*e*g,l=a-.25*i*g+(1-f)*e*h,m=b-.25*i*h-(1-f)*e*g,n=a-.5*i*g+e*h,o=b-.5*i*h-e*g,p=c+f*e*h,q=d-f*e*g,r=a-.75*i*g+(1-f)*e*h,s=b-.75*i*h-(1-f)*e*g;return"M "+a+" "+b+" Q "+j+" "+k+" "+l+" "+m+" T "+n+" "+o+" M "+c+" "+d+" Q "+p+" "+q+" "+r+" "+s+" T "+n+" "+o}function EdenScriptGutter(a,b,c){function d(){console.log("GUTTER HOLD"),i=void 0;for(var a=0;a');var h="http://www.w3.org/2000/svg";this.brace=document.createElementNS(h,"svg"),this.brace.style.position="absolute",this.brace.style.display="none",this.brace.setAttribute("width","22"),this.brace.style.left="10px",this.bracepath=document.createElementNS(h,"path"),this.bracepath.setAttribute("style","stroke: #444; fill: none; stroke-width: 3px"),this.brace.appendChild(this.bracepath),this.gutter=this.$gutter.get(0),a.insertBefore(this.gutter,a.firstChild),a.insertBefore(this.brace,a.firstChild),this.ast=void 0,this.lines=[],this.errors=[],this.agents={},this.hovering=!1,this.ctx=void 0,this.edits=void 0;var i,j,k=!1,l=0,m=!1,n=!1;this.curline=-1,this.textwidth=getTextWidth("M","14px/20px Roboto Mono,monospace"),g.startHover=e,g.endHover=f,this.$gutter.on("mousedown",".eden-gutter-item",function(a){if(!this.edits&&!g.ast.hasErrors()){var b=parseInt(a.target.getAttribute("data-line"));j=a.shiftKey,l=b,m=!!g.lines[b]&&g.lines[b].selected,k=a.shiftKey,n=g.lines[b]&&g.lines[b].live;var c=g.ast.getStatementByLine(b);if(c){var e=c.getRange();if(g.lines[b].live&&!j)if(g.lines[b].selected)for(var f=0;f"+b+"";case"undefined":return"@";case"string":return""+b+"";case"number":return""+b+"";default:return b}}function _formatFramerVal(a){var b=Eden.prettyPrintValue("",a,200,!1,!1);switch(typeof a){case"boolean":return""+b+"";case"undefined":return"@";case"string":return""+b+"";case"number":return""+b+"";default:return b}}CSSUtil={},CSSUtil.setStyle=function(a,b){function c(a,b){return"-"+b.toLowerCase()}var d=a.style;if(void 0===b)d.cssText="";else if("object"==typeof b){var e=/([A-Z])/g,f=/^\w*[A-Z]\w*$/,g="";for(var h in b)if("string"==typeof b[h]){var i;i=f.test(h)?h.replace(e,c):h,g=g+i+": "+b[h]+";\n"}d.cssText=g}else d.cssText=b},CSSUtil.getStyle=function(a){for(var b=document.styleSheets,c=b.length-1;c>=0;c--)for(var d=b[c].cssRules,e=d.length-1;e>=0;e--)if(d[e].type==CSSRule.STYLE_RULE&&d[e].selectorText==a)return d[e].style;var f=document.getElementById("javascript-injected-styles");if(null===f){var g=document.getElementsByTagName("body")[0];f=document.createElement("style"),f.id="javascript-injected-styles",g.appendChild(f)}var h=f.sheet;return h.insertRule(a+"{ }",h.cssRules.length),h.cssRules[0].style},EdenUI.plugins.ScriptInput=function(a,b){EdenUI.plugins.ScriptInput.title=Language.ui.input_window.title,EdenUI.plugins.ScriptInput.description=Language.ui.input_window.description;var c=this;$(document.body).delegate(null,"drop",function(b){if(void 0!==b.originalEvent.dataTransfer){var c=b.originalEvent.dataTransfer.getData("selector");if(!c||""==c)return console.log(b.originalEvent.dataTransfer.files),void b.preventDefault();var d=(c.sp,c.replace(/[^a-zA-Z0-9]+/g,""));eden.root.lookup("view_"+d+"_tabs").assign([c],eden.root.scope,Symbol.hciAgent),a.createView(d,"ScriptInput"),eden.root.lookup("view_"+d+"_current").assign(0,eden.root.scope,Symbol.hciAgent)}}).delegate(null,"dragover",function(a){a.preventDefault()}),this.createCommon=function(a,b,c,d){function e(a,b){b?(M.style.display="flex",I.parentNode.style.top="35px"):(M.style.display="none",I.parentNode.style.top="0")}function f(a,b){b?(N.style.display="flex",O.codearea.style.top="30px"):(N.style.display="none",O.codearea.style.top="0")}function g(a,b){O.setReadonly(b)}function h(a,b){"number"==typeof b&&b>=0&&b=0?T.push(d[g]):T.push(new Eden.Fragment(b[f]))}R=-2,h(aa,aa.value())}}function j(b){""==b&&(b="*");var c=eden.root.lookup("view_"+a+"_query").value();void 0===c&&(c=".type(script).name");var d=Eden.Selectors.query(c,"path,name,remote,executed,type");O.outdiv.innerHTML="";for(var e=0;e
'+f+"
"+g+"");O.outdiv.appendChild(i.get(0))}}function k(){if(R>=0){var a='',b=T[R];b&&b.scratch&&!b.edited?a+='':b&&b.scratch&&(a+=''),L.html(a)}else L.html("")}function l(a,b,c,d,e){var f=document.createElement("div");f.style.left=""+160*e+"px";var g="agent-tab noselect";g+=d?" agent-tab-current handle":" agent-tab-notcurrent";var h=T[b].getTitle();h.length>18&&(h="..."+h.slice(-15));var i;i=T[b]&&T[b].ast?T[b].ast.errors&&T[b].ast.errors.length>0?"tab-icon errored":T[b].originast&&T[b].originast.executed?"tab-icon executed":"tab-icon":"tab-icon noagent";var j="";T[b].remote?j="":void 0===T[b].origin?j="":T[b].locked&&(j=""),f.className=g,f.innerHTML=""+j+""+h+"",f.draggable=!0,f.setAttribute("data-index",b),a.appendChild(f)}function m(){for(;M.firstChild;)M.removeChild(M.firstChild);var a=aa.value(),b=document.createElement("div");if(b.className="agent-tab-more",b.innerHTML="",M.appendChild(b),T.length>3&&0!=a){var c=document.createElement("div");c.className="agent-tableft noselect",M.appendChild(c)}var d=document.createElement("div");d.className="agent-tab-container",M.appendChild(d),a>ea+(fa-1)&&(ea=a-(fa-1)),a3&&a!=T.length-1){var h=document.createElement("div");h.className="agent-tabright noselect",M.appendChild(h)}var i=document.createElement("div");i.className="script-input-windowcontrols",i.innerHTML="",M.appendChild(i)}function n(b){return"view_"+a+"_"+b}function o(){R>=0&&T[R]&&(T[R].originast?(console.log("ONRUN",T[R].originast),T[R].ast.executeStatement(T[R].originast,0,T[R])):T[R].ast.execute(T[R]),m())}function p(){aa.assign(-1,eden.root.scope,Symbol.localJSAgent)}function q(a){var b=a.currentTarget.getAttribute("data-index");aa.assign(parseInt(b),eden.root.scope,Symbol.hciAgent),O.intextarea.focus()}function r(a){var b=parseInt(a.currentTarget.parentNode.getAttribute("data-index"));if(b>=0&&b=c.length&&aa.assign(d-1,eden.root.scope,Symbol.localJSAgent)}a.stopPropagation()}function s(){var a=R;a--,a>=0&&aa.assign(a,eden.root.scope,Symbol.hciAgent)}function t(){var a=R;a++,a=0&&(d.splice(e,1),e--,e<0&&(e=0),e
\t
\t\t
\t\t
\t
'),I=H.find(".inputhider").get(0),J=H.find(".info-bar").get(0),K=H.find(".agent-tabs"),L=H.find(".control-bar"),M=K.get(0),N=L.get(0);$(J).hide();var O=new EdenUI.ScriptArea;I.appendChild(O.contents);var P=0,Q=void 0;I.addEventListener("scroll",function(a){void 0!==Q&&clearTimeout(Q),document.activeElement!==O.outdiv&&(Q=setTimeout(function(){Q=void 0;var a=I.scrollTop;a=Math.floor((a-50)/20),a<0&&(a=0),Math.abs(a-P)>=50&&(console.log("FORCE RE HIGHLIGHT",a),O.highlighter.setScrollTop(a),P=a,O.updateCachedHighlight(),O.gutter.clear())},100))});var R=-1,S=[],T=[],U="view_"+a+"_current",V="view_"+a+"_showtabs",W="view_"+a+"_showbuttons",X="view_"+a+"_tabs",Y="view_"+a+"_zoom",Z="view_"+a+"_readonly",_=eden.root.lookup(X),aa=(eden.root.lookup(Y),eden.root.lookup(U)),ba=eden.root.lookup(V),ca=eden.root.lookup(W),da=eden.root.lookup(Z),ea=0,fa=3,ga=1;void 0===ba.value()&&void 0===ba.definition&&ba.assign(!0,eden.root.scope,Symbol.defaultAgent),ba.addJSObserver("scriptview_"+a,e),e(ba,ba.value()),void 0===ca.value()&&void 0===ca.definition&&ca.assign(!0,eden.root.scope,Symbol.defaultAgent),ca.addJSObserver("scriptview_"+a,f),f(ca,ca.value()),da.addJSObserver("scriptview_"+a,g),g(da,da.value()),aa.addJSObserver("scriptview_"+a,h),_.addJSObserver("scriptview_"+a,i),i(_,_.value()),void 0===_.value()&&void 0===_.definition&&_.assign([],eden.root.scope,Symbol.defaultAgent),void 0===aa.value()&&void 0===aa.definition&&aa.assign(-1,eden.root.scope,Symbol.defaultAgent),Eden.Fragment.listenTo("changed",O,function(a){a===T[R]&&(m(),k(),O.refresh())}),Eden.Fragment.listenTo("locked",O,function(a){a===T[R]&&(console.log("LOCKED",a),h(aa,aa.value()))}),Eden.Fragment.listenTo("unlocked",O,function(a){a===T[R]&&h(aa,aa.value())}),Eden.Fragment.listenTo("errored",O,function(a){}),Eden.Fragment.listenTo("status",O,function(a){a===T[R]&&(m(),k())}),Eden.Fragment.listenTo("gotoline",O,function(a,b){for(var c=0;c').html(h.contents).dialog({appendTo:"#jseden-views",title:d,width:600,height:i,minHeight:203,minWidth:300,classes:{"ui-dialog":"input-dialog ui-front no-print"},resizeStop:h.resize,draggable:!1}),$dialog.parent().draggable({handle:".handle",cancel:".agent-tab-notcurrent",stop:function(a,b){var c=eden.root;c.beginAutocalcOff(),f(g,"x").assign(b.position.left,eden.root.scope,Symbol.hciAgent),f(g,"y").assign(b.position.top,eden.root.scope,Symbol.hciAgent),c.endAutocalcOff()},start:function(a,b){if(f(g,"x").eden_definition||f(g,"y").definition)return!1}}),h.confirmClose=!1,h},this.createEmbedded=function(a,b,d){var e=c.createCommon(a,b,d,!0);return e},a.views.ScriptInput={dialog:this.createDialog,embed:this.createEmbedded,title:Language.ui.input_window.title,category:a.viewCategories.interpretation,menuPriority:0},a.history=this.history,b()},EdenUI.plugins.ScriptInput.getRequiredHeight=function(a,b){return b?55+20*a+20:45+20*a+20},EdenUI.plugins.ScriptInput.dialogs={},EdenUI.plugins.ScriptInput.dialogs.newAgent=function(a,b){var c=$('
'),d=$('
Create Tab:

'),e=d.find(".searchbox").get(0),f=d.find(".namebox").get(0);d.on("click",".button-cancel",function(){a.get(0).removeChild(c.get(0)),b(!1)}),d.on("click",".button-search",function(){a.get(0).removeChild(c.get(0)),b(!0,e.value)}),d.on("click",".button-new",function(){eden.project.addAction(f.value),a.get(0).removeChild(c.get(0)),b(!0,"."+f.value)}),c.append(d),a.append(c)},EdenUI.plugins.ScriptInput.dialogs.localChanges=function(a,b,c){EdenUI.plugins.ScriptInput.dialogs.hide&&EdenUI.plugins.ScriptInput.dialogs.hide();var d=$('
'),e=$('
You have local changes to '+c.name+', use these?

');e.on("click",".button-ok",function(){a.get(0).removeChild(d.get(0)),EdenUI.plugins.ScriptInput.dialogs.hide=void 0,b(!0)}).on("click",".button-cancel",function(){a.get(0).removeChild(d.get(0)),EdenUI.plugins.ScriptInput.dialogs.hide=void 0,b(!1)}),d.append(e),a.append(d),EdenUI.plugins.ScriptInput.dialogs.hide=function(){EdenUI.plugins.ScriptInput.dialogs.hide=void 0,a.get(0).removeChild(d.get(0)),b(!1)}},EdenUI.plugins.ScriptInput.dialogs.uploadFailed=function(a,b){var c=$('
'),d=$('
Upload Failed! Try again...

');d.on("click",".button-upload",function(){a.get(0).removeChild(c.get(0)),b(!0)}).on("click",".button-cancel",function(){a.get(0).removeChild(c.get(0)),b(!1)}),c.append(d),a.append(c)},EdenUI.plugins.ScriptInput.dialogs.uploadAgent=function(a,b){var c=$('
'),d=$('
Upload agent. Give an optional version name:

Public

'),e=d.find(".tagname"),f=d.find(".makepublic"),g=e.get(0).nextSibling,h=!0;d.on("input blur",".script-subdialog-text",function(){var a=e.get(0).value;console.log(a),""==a?(h=!0,g.className="addnew"):/^[a-z][a-z0-9]+$/i.test(a)?(g.className="addnew",h=!0):(g.className="invalid",h=!1)}).on("click",".button-upload",function(){h&&(a.get(0).removeChild(c.get(0)),b(!0,e.get(0).value,f.get(0).checked))}).on("click",".button-cancel",function(){a.get(0).removeChild(c.get(0)),b(!1)}),c.append(d),a.append(c)},EdenUI.plugins.ScriptInput.dialogs.showHistory=function(a,b,c){function d(){for(var a=j.get(0);a.firstChild;)a.removeChild(a.firstChild);g=void 0}function e(a){if(c.history[a])for(var b=c.history[a].length-1;b>=0;b--){var d=$('
');l==b&&(d.addClass("current"),d.addClass("original"),g=d),d.get(0).setAttribute("data-index",""+b);var e=$('
'),f=$('
'),h=$('
');f.html(get_time_diff(c.history[a][b].time)),f.get(0).title=c.history[a][b].time,c.history[a][b].bookmark&&e.addClass("bookmarked"),c.history[a][b].title?h.html(c.history[a][b].title):h.html("[Autosave]"),d.append(e),d.append(h),d.append(f),j.append(d)}}function f(a){if(Eden.DB.getVersions(c.name,function(b){if(null!=b)for(var c=0;c');b[c].saveID==m&&(d.addClass("original"),l==-1&&(d.addClass("current"),g=d)),d.get(0).setAttribute("data-version",""+b[c].saveID);var f="script-history-stored";f+=0==b[c].public?" private":b[c].mine?" mine":" public";var h=$('
'),i=b[c].date.split(/[- :]/),k=$('
'+get_time_diff(new Date(i[0],i[1]-1,i[2],i[3],i[4],i[5]).getTime()/1e3)+"
"),n=b[c].tag;null==b[c].tag&&(n=b[c].saveID);var o=$('
'+n+" ("+b[c].saveID+") by "+b[c].name+"
");d.append(h),d.append(o),d.append(k),j.append(d),b[c].saveID==m&&e(a)}}),c.history.origin){var b=$('
');"origin"==m&&(b.addClass("original"),l==-1&&(b.addClass("current"),g=b)),b.get(0).setAttribute("data-version","origin");var d="script-history-bookmark",f=$('
'),h="origin";c.meta&&c.meta.file&&(h=c.meta.file);var i=$('
'+h+"
");b.append(f),b.append(i),j.append(b),"origin"==m&&e("origin")}}var g,h=$('
'),i=$('
Agent History:
'),j=i.find(".script-history-list"),k=!0,l=c.index,m=c.meta.saveID;f(c.meta.saveID),i.on("input",".script-history-content",function(a){var b=parseInt(a.target.parentNode.getAttribute("data-index"));c.history[c.meta.saveID][b].title=a.target.textContent,c.saveHistory(),c.makeSnapshot(b)}).on("click",".script-history-item",function(a){var b=a.currentTarget.getAttribute("data-version");if(b)"origin"!=b&&(b=parseInt(b)),m=b,d(),l=-1,f(m);else{var c=parseInt(a.currentTarget.getAttribute("data-index"));l=c,g&&g.removeClass("current"),g=$(a.currentTarget),g.addClass("current")}}).on("click",".script-history-bookmark",function(a){var b=parseInt(a.target.parentNode.getAttribute("data-index"));void 0===c.history[c.meta.saveID][b].bookmark?c.history[c.meta.saveID][b].bookmark=!0:c.history[c.meta.saveID][b].bookmark=!c.history[c.meta.saveID][b].bookmark,c.saveHistory(),c.history[c.meta.saveID][b].bookmark?a.target.className="script-history-bookmark bookmarked":a.target.className="script-history-bookmark"}).on("click",".button-ok",function(){k&&(a.get(0).removeChild(h.get(0)),console.log("Rollback to: "+l+"@"+m),b(!0,l,m))}).on("click",".button-cancel",function(){a.get(0).removeChild(h.get(0)),b(!1)}),h.append(i),a.append(h)},EdenUI.plugins.ScriptInput.dialogs.browseAgents=function(a,b,c){function d(a,b,d){Eden.DB.getDirectory(d,function(e){if(void 0!==e){var f=[];for(var g in e)f.push(g);f.sort(function(a,b){return a.toLowerCase().localeCompare(b.toLowerCase())});for(var h=0;h'),m=$('
'),n=$('
'),o=$('
');(function(a,b,d,e,f){Eden.DB.getMeta(b,function(b,f){if(f){var g="";if(f.date){var h=f.date.split(/[- :]/);g=get_time_diff(new Date(h[0],h[1]-1,h[2],h[3],h[4],h[5]).getTime()/1e3)}var i=f.title;if("Script View"!=i&&void 0!==i||(i=""),a.html(d+' '+i+''+g+""),f.remote&&f.defaultID==-1&&f.latestID==-1)e.html(" ");else{var j=$('');e.append(j),c.indexOf(b)>=0&&(j.get(0).checked=!0)}}else a.html(d),e.html(" ")})}).call(this,n,j,k,o,m),Eden.Agent.agents[j]&&l.addClass("loaded"),l.get(0).setAttribute("data-path",j),l.get(0).setAttribute("data-depth",""+(b+1)),l.append(m),l.append(o),l.append(n),void 0===a||void 0===a.nextSibling?i.append(l):i.get(0).insertBefore(l.get(0),a.nextSibling)}}})}function e(a){for(var b=parseInt(a.getAttribute("data-depth")),c=a.nextSibling;c;){var d=parseInt(c.getAttribute("data-depth"));if(!(d>b))break;var e=c.nextSibling;i.get(0).removeChild(c),c=e}}function f(){a.append(g),i.scrollTop(j)}var g=$('
'),h=$('
'+Language.ui.input_window.browse_agents+':
'),i=h.find(".script-agents-list"),j=0,k={};return d(void 0,0,""),h.on("click",".script-agents-item",function(a){}).on("click",".script-agents-expand",function(a){var b=a.currentTarget.parentNode.getAttribute("data-path"),c=parseInt(a.currentTarget.parentNode.getAttribute("data-depth"));a.currentTarget.className.indexOf("expanded")<0?(d(a.currentTarget.parentNode,c,b),changeClass(a.currentTarget,"expanded",!0)):(e(a.currentTarget.parentNode),changeClass(a.currentTarget,"expanded",!1))}).on("change",".script-agents-cbcont input",function(a){var b=a.currentTarget.parentNode.parentNode.getAttribute("data-path");a.currentTarget.checked?k[b]=!0:k[b]=!1}).on("click",".button-add",function(){j=i.scrollTop(),a.get(0).removeChild(g.get(0)),b(!0,k)}).on("click",".button-cancel",function(){j=i.scrollTop(),a.get(0).removeChild(g.get(0)),b(!1)}),g.append(h),{show:f}},EdenScriptGutter.prototype.clear=function(){for(this.ast=void 0,this.lines=[],this.curline=-1,this.hideBrace();this.gutter.firstChild;)this.gutter.removeChild(this.gutter.firstChild)},EdenScriptGutter.prototype.setBaseAST=function(a,b){for(;this.gutter.firstChild;)this.gutter.removeChild(this.gutter.firstChild);this.ast=a,this.errors=b,this.lines=[],this.edits=void 0,this.hideBrace()},EdenScriptGutter.prototype.executeSelected=function(){if(void 0!==this.ast){console.log("EXE SEL",this.ast);for(var a=0;a0)){if(this.curline>=0){ -var c=this.ast.getStatementByLine(this.curline);if(c){var d=c.getRange(),e=Math.floor((d[1]-d[0])/2)+d[0];b||(changeClass(this.gutter.childNodes[e],"play",!1),changeClass(this.gutter.childNodes[e],"current",!1))}}this.curline=a-1;var c=this.ast.getStatementByLine(a-1);if(c){c.getRange||console.error("NO GETRANGE",c);var d=c.getRange();if(d[0]0?(j.errors[0].line==a+1?(c+=" error",e="",i=j.errors[0].messageText(),h=a):"runtime"==j.errors[0].type&&(c+=" error",e="",i=j.errors[0].messageText()),this.lines[a].errored=!0,g=!0):(d.errors.length>0&&d.errors[0].line==a+1&&(this.lines[a].errored=!0,c+=" error",e="",i=d.errors[0].messageText()),this.lines[a].errored&&(g=!0,this.lines[a].errored=!1),j.warning&&(c+=" warning",e="",g=!0,j.warning&&(i=j.warning.messageText())),1==j.executed?(c+=" executed",g=!0,this.lines[a].executed=!0):2==j.executed?(c+=" guarded",g=!0,this.lines[a].executed=!0):3==j.executed&&(c+=" errorblock",g=!0)),this.lines&&this.lines[a]&&(this.lines[a].executed&&j.executed<=0&&(g=!0,this.lines[a].executed=!1),this.lines[a].selected&&(c+=" select"),this.lines[a].live&&(c+=" live"))):(this.errors&&this.errors.length>0&&this.errors[0].line==a+1?this.lines[a].errored||(c+=" error",e="",i=this.errors[0].messageText(),h=a,this.lines[a].errored=!0,g=!0):this.lines[a].errored&&(g=!0,this.lines[a].errored=!1,i=""),this.lines[a].executed&&(g=!0,this.lines[a].executed=!0)),f)if(""==e){var k=document.createElement("div");k.className=c,k.innerHTML="",k.setAttribute("data-line",""+a),this.gutter.replaceChild(k,this.gutter.childNodes[a])}else this.gutter.childNodes[a].className=c,this.gutter.childNodes[a].innerHTML=e;else g&&(this.gutter.childNodes[a].className.indexOf("hover")>=0&&(c+=" hover"),this.gutter.childNodes[a].className.indexOf("play")>=0&&(c+=" play"),this.gutter.childNodes[a].className.indexOf("current")>=0&&(c+=" current"),this.gutter.childNodes[a].innerHTML=e,this.gutter.childNodes[a].className=c,i&&(this.gutter.childNodes[a].title=i))},EdenScriptGutter.prototype.generate=function(a,b){if(this.ast=a,!this.edits){var c=!1,d=a.getNumberOfLines()+1;if(d>this.lineelements.childNodes.length&&(d=this.lineelements.childNodes.length),d!=this.gutter.childNodes.length){for(this.hideBrace();this.gutter.firstChild;)this.gutter.removeChild(this.gutter.firstChild);for(var e=0;e0?this.hideBrace():this.hovering||this.selectLine(b)}},EdenUI.ScriptArea=function(){this.contents=document.createElement("div"),this.intextarea=document.createElement("textarea"),this.intextarea.autofocus=!0,this.intextarea.tabIndex=1,this.intextarea.className="hidden-textarea2",this.contents.appendChild(this.intextarea),this.codearea=document.createElement("div"),this.codearea.className="inputCodeArea",this.contents.appendChild(this.codearea),this.outdiv=document.createElement("div"),this.outdiv.contenteditable=!0,this.outdiv.className="outputcontent",this.outdiv.spellcheck=!1,this.outdiv.tabIndex=2,this.codearea.appendChild(this.outdiv),this.fragment=void 0,this.readonly=!1,this.alwaysreadonly=!1,this.currentlineno=-1,this.currentcharno=-1,this.gotomode=!1,this.highlighter=new EdenUI.Highlight(this.outdiv),this.gutter=new EdenScriptGutter(this.codearea,this.infobox,this.outdiv),this.details=new EdenUI.ScriptArea.Details(this),this.cachedhlopt=void 0,this.disablehl=!1,this.highlighter.setScrollTop(0);var a=this;this.gutterinterval=setInterval(function(){if(void 0!==a.fragment&&void 0!==a.fragment.ast){a.gutter.generate(a.fragment.ast.script,a.currentlineno);for(var b in a.highlighter.metrics)if(a.currentlineno!=b){var c=a.highlighter.metrics[b];if(c.query)for(var d=0;d0?f:"value");g=1==g.length?g[0]:g.length>1?g.join(", "):"",c.qelements[d].setAttribute("data-result",g)}c.squery&&a.highlightContent(b,a.intextarea.selectionEnd)}}},300);new EdenUI.ScriptArea.Keyboard(this),new EdenUI.ScriptArea.Mouse(this);this.rebuildinterval=400},EdenUI.ScriptArea.prototype.setReadonly=function(a){this.alwaysreadonly=a,a===!0?(this.readonly=!0,this.outdiv.contentEditable=!1):(this.readonly=!!this.fragment&&this.fragment.locked,this.outdiv.contentEditable=!this.readonly,"comment"==a&&this.updateEntireHighlight())},EdenUI.ScriptArea.prototype.setFragment=function(a){if(this.fragment&&this.fragment!==a&&(this.fragment.unlock(),this.currentlineno=-1),this.details.hide(),this.fragment=a,void 0===a)return this.gutter.clear(),changeClass(this.outdiv,"browser",!0),this.outdiv.contentEditable=!1,void(this.readonly=!0);var b=this;a.reset(function(){changeClass(b.outdiv,"browser",!1),b.intextarea.value=a.getSource(),a.ast&&(b.highlightContent(-1,0),b.intextarea.focus(),b.checkScroll(),b.gutter.setBaseAST(a.ast.script)),a.locked?(b.readonly=!0,b.outdiv.contentEditable=!1):(b.readonly=b.alwaysreadonly===!0,b.outdiv.contentEditable=!b.readonly)})},EdenUI.ScriptArea.prototype.refresh=function(){this.intextarea.value=this.fragment.getSource(),this.fragment.ast&&this.highlightContent(-1,0)},EdenUI.ScriptArea.prototype.updateSource=function(a,b){this.fragment.setSource(a),this.gutter.errors=this.fragment.ast.errors,this.highlighter.ast=this.fragment.ast},EdenUI.ScriptArea.prototype.updateLineHighlight=function(){var a=-1,b=-1;document.activeElement===this.intextarea&&(b=this.intextarea.selectionEnd,a=this.getLineNumber(this.intextarea)),this.updateSource(this.intextarea.value,a),this.runScript(a),this.highlightContent(a,b)},EdenUI.ScriptArea.prototype.runScript=function(a){if(this.gutter.lines[a-1]&&this.gutter.lines[a-1].live&&!this.fragment.ast.hasErrors()){var b=this.fragment.ast.script.getStatementByLine(a-1);this.fragment.ast.executeStatement(b,a,this.fragment)}},EdenUI.ScriptArea.prototype.hideInfoBox=function(){},EdenUI.ScriptArea.prototype.updateLineCachedHighlight=function(){if(this.fragment){var a=-1,b=-1;document.activeElement===this.intextarea&&(b=this.intextarea.selectionEnd,a=this.getLineNumber(this.intextarea)),this.highlightContent(a,b)}},EdenUI.ScriptArea.prototype.updateEntireHighlight=function(a,b){if(void 0!==this.fragment){this.cachedhlopt=b,this.updateSource(this.intextarea.value,-1);var c=-1;document.activeElement===this.intextarea&&(c=this.intextarea.selectionEnd),a&&runScript(0),this.highlightContent(-1,c,b)}},EdenUI.ScriptArea.prototype.updateCachedHighlight=function(a){var b=-1;document.activeElement===this.intextarea&&(b=this.intextarea.selectionEnd),this.highlightContent(-1,b,a?a:this.cachedhlopt)},EdenUI.ScriptArea.prototype.findElementLineNumber=function(a){for(var b=a;b.parentNode!==this.outdiv;)b=b.parentNode;var c=parseInt(b.getAttribute("data-line"));return c},EdenUI.ScriptArea.prototype.replaceLine=function(a,b){var c=this.intextarea.value.split("\n");c[a]=b,this.intextarea.value=c.join("\n")},EdenUI.ScriptArea.prototype.focusOutput=function(){this.setCaretToFakeCaret(),this.outdiv.focus()},EdenUI.ScriptArea.prototype.focusText=function(){if(!this.readonly){var a=getCaretCharacterOffsetWithin(this.outdiv),b=getStartCaretCharacterOffsetWithin(this.outdiv);this.intextarea.focus(),this.intextarea.selectionEnd=a,this.intextarea.selectionStart=b,b!=a&&(this.refreshentire=!0)}},EdenUI.ScriptArea.prototype.toggleHighlighting=function(){this.disablehl=!this.disablehl,this.updateEntireHighlight(),this.gutter.clear()},EdenUI.ScriptArea.prototype.highlightContent=function(a,b,c){if(this.fragment){var d=this.fragment.ast;if(d){if(void 0===c&&this.disablehl&&(c={}),this.disablehl&&(c.disabled=!0),this.highlighter.highlight(d,a,b,c),document.activeElement!==this.intextarea&&$(this.outdiv).find(".fake-caret").addClass("fake-blur-caret"),"comment"==this.alwaysreadonly)for(var e=$(this.outdiv).find(".eden-comment-line"),f=0;f")},axis:"x",distance:5,drag:function(b,c){if(!a.readonly){var d;if(a.dragint?d=Math.round(a.dragvalue+(c.position.left-a.dragstart)/2):(d=a.dragvalue+.005*(c.position.left-a.dragstart),d=d.toFixed(4)),d!=a.draglast){a.draglast=d,b.target.innerHTML=""+d;var e=b.target.parentNode.textContent;"\n"==e.charAt(e.length-1)&&(e=e.slice(0,-1)),a.replaceLine(a.dragline,e),a.updateSource(a.intextarea.value,a.dragline),a.runScript(a.dragline+1),a.highlightContent(a.dragline,-1)}}},start:function(b,c){if(!a.readonly){a.edited=!0,a.dragline=a.findElementLineNumber(b.target),a.dragstart=c.position.left;var d=b.target.textContent;d.indexOf(".")==-1?(a.dragvalue=parseInt(d),a.dragint=!0):(a.dragvalue=parseFloat(d),a.dragint=!1),a.draglast=a.dragvalue,$(b.target).addClass("eden-select"),$(a.outdiv).css("cursor","ew-resize")}},stop:function(b,c){a.readonly||($(b.target).removeClass("eden-select"),$(a.outdiv).css("cursor","text"),a.dragline=-1)},cursor:"move",cursorAt:{top:-5,left:-5}}).click(function(){$(this).draggable({disabled:!0})}).blur(function(){$(this).draggable({disabled:!1})}))},EdenUI.ScriptArea.prototype.getLineNumber=function(){var a=this.intextarea.value.substr(0,this.intextarea.selectionStart).split("\n");return this.currentlineno=a.length,this.currentcharno=a[a.length-1].length,this.currentlineno},EdenUI.ScriptArea.prototype.gotoLine=function(a){var b=this.intextarea.value.split("\n");b.length=a+1;var c=b.join("\n").length;this.intextarea.focus(),this.intextarea.selectionEnd=c,this.intextarea.selectionStart=c,this.updateLineCachedHighlight()},EdenUI.ScriptArea.prototype.checkScroll=function(){return},EdenUI.ScriptArea.prototype.setCaretToFakeCaret=function(){var a=$(this.outdiv).find(".fake-caret").get(0);if(a){var b=document.createRange(),c=window.getSelection();a.nextSibling&&(a=a.nextSibling),b.setStart(a,0),b.collapse(!0),c.removeAllRanges(),c.addRange(b),$(this.outdiv).remove(".fake-caret")}},EdenUI.ScriptArea.prototype.makeDiff=function(){var a={},b=this.fragment.diff(),c=0;for(var d in b.remove)if(!b.remove[d].consecutive){var e=parseInt(d),f=0,g=20;do g+=20,f++;while(b.remove[e+f]&&b.remove[e+f].consecutive);a[b.remove[d].nline+c]=g}this.gutter.setDiffs(b),this.cachedhlopt={spacing:a},this.updateCachedHighlight()},EdenUI.ScriptArea.prototype.doRebuild=function(){this.makeNumbersDrag()},EdenUI.ScriptArea.prototype.delayRebuild=function(){var a=this;clearTimeout(this.rebuildtimer),this.rebuildtimer=setTimeout(function(){a.doRebuild()},this.rebuildinterval)},EdenUI.ScriptArea.prototype.rebuild=function(){this.gutter.edits?(this.updateSource(this.intextarea.value,-1),this.gutter.ast=this.fragment.ast,this.makeDiff()):(this.edited=!0,this.refreshentire?(this.updateEntireHighlight(),this.refreshentire=!1):this.updateLineHighlight(),this.checkScroll(),this.dirty=!1)},EdenUI.ScriptArea.prototype.enableGotoMode=function(){this.gotomode||(this.outdiv.contentEditable=!1,changeClass(this.outdiv,"goto",!0),this.gotomode=!0)},EdenUI.ScriptArea.prototype.disableGotoMode=function(){this.gotomode&&(this.outdiv.contentEditable=!0,changeClass(this.outdiv,"goto",!1),this.gotomode=!1)},EdenUI.ScriptArea.prototype.insertTab=function(){var a=this.intextarea.selectionStart,b=this.intextarea.selectionEnd;this.intextarea.value=this.intextarea.value.substring(0,a)+"\t"+this.intextarea.value.substring(b),this.intextarea.selectionStart=this.intextarea.selectionEnd=a+1,this.rebuild()},EdenUI.ScriptArea.Details=function(a){this.scriptarea=a,this.contents=document.createElement("div"),this.contents.className="script-details",this.contents.addEventListener("keyup",function(a){var b=a.target.parentNode.getAttribute("data-name"),c=a.target.value;console.log("CHANGE PROP",b,c)}),this.visible=!1},EdenUI.ScriptArea.Details.prototype.addProperty=function(a,b,c,d){var e=document.createElement("div");e.className="script-details-prop",e.setAttribute("data-name",a);var f=document.createElement("div");f.className="script-details-label",f.textContent=b,e.appendChild(f);var g=document.createElement("input");g.className="script-details-value",g.value=c?c:"",g.setAttribute("type","text"),d&&d.readonly&&(g.className+=" script-details-readonly",g.setAttribute("readonly","true")),e.appendChild(g);var h=document.createElement("div");return h.className="script-details-status",d&&d.readonly?h.innerHTML="":h.innerHTML="",e.appendChild(h),this.contents.appendChild(e),e},EdenUI.ScriptArea.Details.prototype.clear=function(){for(;this.contents.lastChild;)this.contents.removeChild(this.contents.lastChild)},EdenUI.ScriptArea.Details.prototype.addButtons=function(){var a=document.createElement("div");a.className="script-details-buttons";var b=document.createElement("button");b.className="script-button",b.innerHTML='Close',a.appendChild(b),this.contents.appendChild(a)},EdenUI.ScriptArea.Details.prototype.show=function(){this.clear(),this.addProperty("name","Name",this.scriptarea.fragment.name),this.addProperty("selector","Path",this.scriptarea.fragment.selector,{readonly:!0}),this.scriptarea.fragment.originast&&this.addProperty("id","Full Name",Eden.Selectors.getID(this.scriptarea.fragment.originast),{readonly:!0});var a=this.scriptarea.fragment.doxy;if(a){this.addProperty("desc","Description",a.stripped()),this.addProperty("tags","Tags",a.getHashTags().join(" "));var b=a.getControls();for(var c in b)this.addProperty(c,c.substring(1),b[c])}this.addButtons(),this.scriptarea.codearea.appendChild(this.contents),changeClass(this.scriptarea.outdiv,"blur",!0),this.visible=!0},EdenUI.ScriptArea.Details.prototype.hide=function(){this.visible&&(this.scriptarea.codearea.removeChild(this.contents),this.visible=!1,changeClass(this.scriptarea.outdiv,"blur",!1))},EdenUI.ScriptArea.Details.prototype.toggle=function(){this.visible?this.hide():this.show()},EdenUI.ScriptArea.Keyboard=function(a){function b(a){var b=a.key;return a.shiftKey&&(b="Shift-"+b),a.altKey&&(b="Alt-"+b),(a.ctrlKey||a.metaKey)&&(b="Ctrl-"+b),b}function c(c){var d=b(c);switch(d){case"Tab":c.preventDefault(),a.insertTab();break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Home":case"End":a.moveCaret();break;case"Ctrl-a":a.selectAll(),c.preventDefault();break;case"Ctrl-h":a.toggleHighlighting(),c.preventDefault();break;case"Ctrl-Shift-ArrowLeft":case"Ctrl-Shift-ArrowRight":case"Ctrl-Shift-ArrowUp":case"Ctrl-Shift-ArrowDown":case"Ctrl-Shift-Home":case"Ctrl-Shift-End":case"Shift-ArrowLeft":case"Shift-ArrowRight":case"Shift-ArrowUp":case"Shift-ArrowDown":case"Shift-Home":case"Shift-End":a.focusOutput();break;case"Backspace":a.refreshentire=10==a.intextarea.value.charCodeAt(a.intextarea.selectionStart-1);break;case"Enter":a.refreshentire=!0;break;case"Ctrl-Control":a.enableGotoMode()}}function d(b){a.refreshentire=!0}function e(c){var d=b(c);switch(c.ctrlKey||a.disableGotoMode(),d){case"Ctrl-Control":a.disableGotoMode();break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Home":case"End":a.updateLineCachedHighlight(),a.gutter&&a.gutter.selectLine(a.currentlineno),a.checkScroll()}}function f(b){"INPUT"!=b.target.nodeName&&"textarea"!=b.target.nodeName&&(!b.shiftKey||37!=b.keyCode&&38!=b.keyCode&&39!=b.keyCode&&40!=b.keyCode&&35!=b.keyCode&&36!=b.keyCode)&&"Control"!=b.key&&"Shift"!=b.key&&"c"!=b.key&&a.focusText()}function g(b){a.intextarea.focus(),setTimeout(function(){a.updateEntireHighlight()},0)}function h(b){"INPUT"!=b.target.nodeName&&"textarea"!=b.target.nodeName&&(17!=b.keyCode&&91!=b.keyCode&&92!=b.keyCode||a.disableGotoMode())}function i(b){$(a.outdiv).find(".fake-caret").remove()}function j(b){a.dirty=!0,a.rebuild()}function k(a){}a.intextarea.addEventListener("input",j),a.intextarea.addEventListener("keydown",c),a.intextarea.addEventListener("keyup",e),a.intextarea.addEventListener("paste",d),a.outdiv.addEventListener("keydown",f),a.outdiv.addEventListener("keyup",h),a.outdiv.addEventListener("paste",g),a.intextarea.addEventListener("blur",i),a.intextarea.addEventListener("focus",k)},EdenUI.ScriptArea.Mouse=function(a){function b(b){a.readonly}function c(b){if(console.log(b.target.nodeName),"INPUT"!=b.target.nodeName&&"textarea"!=b.target.nodeName&&(a.hideInfoBox(),!a.readonly&&0!=b.target.isContentEditable))if(a.gotomode){var c=b.target;if(""==c.className&&"SPAN"==c.parentNode.nodeName&&(c=c.parentNode),"eden-selector"==c.className||"eden-selector2"==c.className){a.disableGotoMode();var d=c.parentNode.textContent;console.log("PATH",d),Eden.Selectors.goto(d)}else if("eden-observable"==c.className){var e=c.getAttribute("data-observable");Eden.Selectors.goto(e+":active")}b.preventDefault()}else if(document.activeElement===a.outdiv){var f=getCaretCharacterOffsetWithin(a.outdiv),g=getStartCaretCharacterOffsetWithin(a.outdiv);if(g!=f)a.refreshentire=!0;else{a.intextarea.focus(),a.intextarea.selectionEnd=f,a.intextarea.selectionStart=f;a.currentlineno;a.updateLineCachedHighlight()}}}a.outdiv.addEventListener("mouseup",c),a.outdiv.addEventListener("mousedown",b)},EdenUI.plugins.PluginManager=function(a,b){this.createDialog=function(b,c){var d,e,f,g=$('
'),h=function(b){return a.plugins[b]?"(loaded)":"(not loaded)"};pluginNames=Object.keys(EdenUI.plugins).sort(function(b,c){var d=a.plugins[b],e=a.plugins[c];return d&&!e?1:e&&!d?-1:b
'+d.title+"
";void 0!==d.originalAuthor&&(k=k+""),void 0!==d.author&&(f=void 0===d.originalAuthor?"By ":"Built on by ",k=k+""),k=k+'",$(k).click(function(b){return function(){var c=$(this);a.loadPlugin(b,function(){a.plugins[b]&&(c.find(".pluginlist-loaded").html(h(b)),c.addClass("pluginmanager-loaded",100)),a.menu.updateViewsMenu()})}}(e)).appendTo(g)}var l=$('
');l.append(g),$dialog=$('
').html(l).dialog({title:c,width:310,height:400,minHeight:120,minWidth:230,dialogClass:"unpadded-dialog"})},a.views.PluginManager={dialog:this.createDialog,title:"Plug-in Manager",category:a.viewCategories.environment,name:"plugins"},b()},EdenUI.plugins.PluginManager.title="Plug-in Manager",EdenUI.plugins.PluginManager.description="Provides the ability to load plug-ins.",EdenUI.plugins.Canvas2D=function(a,b){var c=this;this.defaultFontSizePx=13.3,this.defaultLineHeight=1.75*this.defaultFontSizePx,this.defaultLineWidth=2;var d=600,e=500;canvases={},contents={};var f,g,h,i={},j=40,k=!1,l=!1;Object.defineProperty(this,"mouseIdleTimeout",{set:function(a){clearInterval(g),g=setInterval(function(){if(k)l=!1,k=!1;else if(!l){var a=root.lookup("mouseFollow").value();root.lookup("mouseVelocity").assign(new Point(0,0),root.scope,Symbol.hciAgent,a),l=!0,h=void 0}},a/2),f=a},get:function(){return f},enumerable:!0}),this.mouseVelocitySampleTime=100,this.mouseVelocityDampening=.3,this.mouseIdleTimeout=300;var m=function(a,b){var c;for(c in b)if("false"!=b[c][0].getAttribute("data-garbage"))for(var d=b[c],e=0;em?(e=j,d=i*(e/h),f=0,g=(k-d)/2):(d=k,e=j,f=0,g=0);var n=document.createElement("canvas");n.setAttribute("width","200"),n.setAttribute("height","112");var o=n.getContext("2d");o.drawImage(b,f,g,e,d);var p;try{p=n.toDataURL("image/png")}catch(q){}a&&a(p)},this.drawPicture=function(a){var b=canvases[a];if(void 0!==b&&!b.drawingQueued&&(b.drawingQueued=!0,!b.drawingInProgress)){var d=function(){b.drawingInProgress=!0,b.drawingQueued=!1;var e=i[a],f={},g="view_"+a+"_content",h=root.lookup(g),k=h.value(),l=b.getContext("2d"),n=contents[a],o=0;if(void 0!==n){var p=root.lookup("view_"+a+"_background_colour").value();void 0===p&&(p="white"),l.setTransform(1,0,0,1,0,0),c.setFillStyle(l,p),n.style.backgroundColor=p,l.fillRect(0,0,b.width,b.height);var q;for(q in e)e[q][0].setAttribute("data-garbage",!0);if(Array.isArray(k)){var r=root.lookup("view_"+a+"_scale").value();"number"!=typeof r&&(r=1);var s=root.lookup("view_"+a+"_zoom").value();"number"!=typeof s&&(s=1);var t,u,v=r*s;r<0?(l.scale(-v,v),v=-v,u=-r,t=!0):(1!=v&&l.scale(v,v),u=r,t=!1);var w=root.lookup("view_"+a+"_offset").value();if(w instanceof Point)if(t){var x=b.height/v-w.y;l.translate(w.x,-x),w=new Point(w.x,x)}else l.translate(w.x,w.y);else w=new Point(0,0);c.configureContextDefaults(l,u);for(var y=[k],z=[0],A=[],B="";y.length>0;){var C=y.pop(),D=z.pop();for(D>0&&C[D-1]instanceof EdenUI.plugins.Canvas2D.Transform&&(l.restore(),A.pop(),B=A.join(" "));D=d;i-=c){var j=(Math.round(i*b)-.5)/b;h.moveTo(j,e),h.lineTo(j,g),h.stroke()}for(var k=0==a.y?c:0;k<=g;k+=c){var l=(Math.round(k*b)-.5)/b;h.moveTo(d,l),h.lineTo(f,l),h.stroke()}for(var k=-c;k>=e;k-=c){var l=(Math.round(k*b)-.5)/b;h.moveTo(d,l),h.lineTo(f,l),h.stroke()}},this.configureContextDefaults=function(a,b){a.lineJoin="bevel",a.miterLimit=429496656,a.lineWidth=this.defaultLineWidth/b},this.configureContext=function(a,b,c,d){if("object"!=typeof d)return!0;if(d.visible===!1)return!1;if(Array.isArray(d.dashes)&&(a.setLineDash(d.dashes),"dashOffset"in d&&(a.lineDashOffset=d.dashOffset)),"cap"in d&&(a.lineCap=d.cap),"join"in d&&(a.lineJoin=d.join),"miterLimit"in d&&(a.miterLimit=d.miterLimit),"lineWidth"in d&&(a.lineWidth=d.lineWidth/b),"opacity"in d&&(a.globalAlpha=d.opacity),"object"==typeof d.shadow)if(a.shadowColor=d.shadow.colour,d.shadow.scale){var e=c*b;a.shadowBlur=d.shadow.blur*e,a.shadowOffsetX=d.shadow.xOffset*e,a.shadowOffsetY=d.shadow.yOffset*e}else a.shadowBlur=d.shadow.blur*c,a.shadowOffsetX=d.shadow.xOffset*c,a.shadowOffsetY=d.shadow.yOffset*c;return!0},this.setFillStyle=function(a,b){b instanceof EdenUI.plugins.Canvas2D.FillStyle?a.fillStyle=b.getColour(a):a.fillStyle=b},this.initZoneFromDrawingOpts=function(b,c){var d;if(b instanceof Object&&b.zone!==!1){if(d=b.name,void 0===d&&b.zone===!0)return root.currentObservableName();if(a.eden.isValidIdentifier(d)){var e=root.lookup(d+"_click");void 0===e.value()&&e.assign(!1,root.scope,root.lookup(c))}return d}},this.initZoneFromName=function(b,c){if(a.eden.isValidIdentifier(b)){var d=root.lookup(b+"_click");void 0===d.value()&&d.assign(!1,root.scope,root.lookup(c))}return b},this.findDrawableHit=function(a,b,c,d,e){var f=root.lookup("view_"+a+"_content").value(),g=canvases[a];if(g){var h=g.getContext("2d"),i=root.lookup("view_"+a+"_scale").value();return this.findDrawableHitInList(f,h,i,b,c,d,e)}},this.findDrawableHitInList=function(a,b,c,d,e,f,g){if(Array.isArray(a)){var h,i;f?(h=0,i=1):(h=a.length-1,i=-1);for(var j=h;f?j=0;j+=i){var k=a[j];if("object"==typeof k)if(Array.isArray(k)){var l=this.findDrawableHitInList(k,b,c,d,e,f,g);if(l)return l}else{var m=k.isHit;if(void 0!==m){if(!g&&void 0===k.name)continue;b.save();var n=k.isHit(b,c,d,e);if(b.restore(),n===!0)return k}else if(k.inverse){var o=k.inverse(d,e),l=this.findDrawableHitInList(k.items,b,c,o.x,o.y,f,g);if(void 0!==l)return l}}}}},this.findAllDrawablesHit=function(a,b,c,d){var e=root.lookup("view_"+a+"_content").value(),f=canvases[a],g=f.getContext("2d"),h=root.lookup("view_"+a+"_scale").value();return this.findAllDrawablesHitInList(e,g,h,b,c,d)},this.findAllDrawablesHitInList=function(a,b,c,d,e,f){if(!Array.isArray(a))return[];for(var g=[],h=0;h0&&(g=g.concat(m))}}}return g};var n={leftButton:!1,middleButton:!1,rightButton:!1,button4:!1,button5:!1,buttonCount:0,insideCanvas:!1,capturing:!1};this.createCommon=function(b,f){function g(){c.drawPicture(s)}function j(a){return"view_"+b+"_"+a}function l(){var b,d,e=x.value(),f=y.value(),g=e*f,h=z.value();h instanceof Point?(b=h.x,d=h.y):(b=0,d=0);var i=A.value();void 0!==i?(i=Math.ceil((A.value()+b)*g),t.width=i):f>1?t.width=Math.ceil(C.value()*f):t.width=Math.floor(C.value());var j;void 0!==B.value()?j=Math.ceil((B.value()+d)*g):f>1?j=Math.ceil(D.value()*f):(j=D.value(),void 0!==i&&i>Math.floor(C.value())&&(j-=a.scrollBarSize),j=Math.floor(j-1)),t.height=j,t.rescale=!0,c.drawPicture(s)}function m(){E?(E=!1,t.rescale=!0,c.drawPicture(s),H||(H=!0,setTimeout(m,1e3))):(l(),H=!1)}function o(a){var b=root.lookup("mouseFollow").value();root.beginAutocalcOff(),n.insideCanvas=!0;var d;switch(a.button){case 0:n.leftButton=!0,root.lookup("mousePressed").assign(!0,root.scope,Symbol.hciAgent,b),d="Left";break;case 1:n.middleButton=!0,d="Middle";break;case 2:n.rightButton=!0,d="Right";break;case 3:n.button4=!0,d="Button4";break;case 4:n.button5=!0,d="Button5";break;default:d="Unknown"}n.buttonCount=n.leftButton+n.middleButton+n.rightButton+n.button4+n.button5;var e="|";if(n.leftButton&&(e+="Left|"),n.middleButton&&(e+="Middle|"),n.rightButton&&(e+="Right|"),n.button4&&(e+="Button4|"),n.button5&&(e+="Button5|"),root.lookup("mouseButtons").assign(e,root.scope,Symbol.hciAgent,b),root.lookup("mouseButton").assign(d+" down",root.scope,Symbol.hciAgent,b),1==n.buttonCount){var f=root.lookup("mousePosition").value();root.lookup("mouseDownView").assign(s,root.scope,Symbol.hciAgent,b),root.lookup("mouseDown").assign(f,root.scope,Symbol.hciAgent,b);var g=root.lookup("view_"+s+"_scale").value(),h=root.lookup("view_"+s+"_zoom").value(),i=g*h,j=$(this).offset(),k=(a.pageX-Math.round(j.left))/i,l=(a.pageY-Math.round(j.top))/i,m=root.lookup("view_"+s+"_offset").value();m instanceof Point&&(k-=m.x,l-=m.y);var o,p=c.findDrawableHit(s,k,l,!1,!1);o=void 0===p?void 0:p.name;var q=root.lookup("mouseZone"),r=q.value();o!==r&&q.assign(o,root.scope,Symbol.hciAgent,b),root.lookup("mouseDownZone").assign(o,root.scope,Symbol.hciAgent,b)}root.endAutocalcOff()}var p,q,r={name:"*Default"},s=b,t=canvases[b];void 0===t?(p=$('
'),p.html(''),q=p.find(".canvashtml-canvas"),t=q[0],canvases[b]=t,contents[b]=p[0],i[b]={},t.drawingQueued=!1,t.drawingInProgress=!1,t.rescale=!1):(p=$("#"+b+"-canvascontent"),q=p.find(".canvashtml-canvas"));var u=[j("content"),j("background_colour"),j("scale"),j("zoom"),j("offset"),j("canvas_right"),j("canvas_bottom"),"mousePosition","mouseButton","mouseButtons","mouseCapture","mouseCaptured","mouseDown","mouseDownView","mouseFollow","mousePressed","mouseUp","mouseWheel","mouseWheelEnabled","mouseWheelVelocity","mouseView","mouseZone","mouseVelocity"];t.setAttribute("data-observables",u.join(",")); -var v=root.lookup("view_"+s+"_content");v.addJSObserver("repaintView",g);var w=root.lookup("view_"+s+"_background_colour");void 0===w.value()&&w.assign("white",root.scope,r),w.addJSObserver("refreshView",g);var x=root.lookup("view_"+s+"_scale"),y=root.lookup("view_"+s+"_zoom"),z=root.lookup("view_"+s+"_offset"),A=root.lookup("view_"+s+"_canvas_right"),B=root.lookup("view_"+s+"_canvas_bottom"),C=root.lookup("view_"+s+"_width"),D=root.lookup("view_"+s+"_height"),E=!1,F=x.value();void 0===F&&(x.assign(1,root.scope,r),F=1),x.addJSObserver("refreshView",l);var G=y.value();void 0===G&&(y.assign(1,root.scope,r),G=1);var H=!1;y.addJSObserver("refreshView",function(a,b){Math.round(100*b);E=!0,m()});var I,J,K=z.value();K instanceof Point?(I=K.x,J=K.y):(z.assign(new Point(0,0),root.scope,r),I=0,J=0),z.addJSObserver("refreshView",l),void 0==A.value()&&A.assign(void 0,root.scope,r),A.addJSObserver("repaintView",l),void 0==B.value()&&B.assign(void 0,root.scope,r),B.addJSObserver("repaintView",l);var L=A.value();L=void 0===L?d:L*F+I;var M=B.value();M=void 0===M?e:M*F+J;var N=root.lookup("view_"+s+"_grid_visible");void 0===N.value()&&N.assign(!1,root.scope,r),N.addJSObserver("refreshView",g);var O=root.lookup("view_"+s+"_grid_spacing");return void 0===O.value()&&O.assign(20,root.scope,r),O.addJSObserver("refreshView",g),q.on("mousedown",o),q.on("mouseup",function(b){var c=root.lookup("mouseFollow").value();root.beginAutocalcOff(),n.insideCanvas=!0;var d;switch(navigator.platform.toUpperCase().indexOf("MAC")>=0&&b.ctrlKey&&(b.button=2),b.button){case 0:n.leftButton=!1,root.lookup("mousePressed").assign(!1,root.scope,Symbol.hciAgent,c),d="Left";break;case 1:n.middleButton=!1,d="Middle";break;case 2:n.rightButton=!1,d="Right";break;case 3:n.button4=!1,d="Button4";break;case 4:n.button5=!1,d="Button5";break;default:d="Unknown"}if(n.buttonCount=n.leftButton+n.middleButton+n.rightButton+n.button4+n.button5,root.lookup("mouseButton").assign(d+" up",root.scope,Symbol.hciAgent,c),0==n.buttonCount){var e=root.lookup("mousePosition").value();root.lookup("mouseButtons").assign("",root.scope,Symbol.hciAgent,c),root.lookup("mouseUp").assign(e,root.scope,Symbol.hciAgent,c),a.plugins.Canvas2D.endClick()}else{var f="|";n.leftButton&&(f+="Left|"),n.middleButton&&(f+="Middle|"),n.rightButton&&(f+="Right|"),n.button4&&(f+="Button4|"),n.button5&&(f+="Button5|"),root.lookup("mouseButtons").assign(f,root.scope,Symbol.hciAgent,c)}root.endAutocalcOff()}).on("contextmenu",function(a){navigator.platform.toUpperCase().indexOf("MAC")>=0&&a.ctrlKey&&(a.button=2,o(a)),root.lookup("mouseContextMenuEnabled").value()||(a.preventDefault(),a.stopPropagation())}).on("click",function(a){root.lookup("mouseCapture").value()&&this.requestPointerLock()}).on("dblclick",function(a){var b=root.lookup("mouseFollow").value(),c=root.lookup("mouseDoubleClicks"),d=c.value();c.assign(d+1,root.scope,Symbol.hciAgent,b)}).on("wheel",function(a){var b,d=a.originalEvent,e=D.value();b=d.deltaMode==WheelEvent.DOM_DELTA_LINE?c.defaultLineHeight:d.deltaMode==WheelEvent.DOM_DELTA_PAGE?0!=d.deltaX?C.value():e:1;var f=root.lookup("mouseFollow").value();if(0!=d.deltaY&&a.ctrlKey&&!a.altKey&&!a.metaKey&&!a.shiftKey){a.preventDefault(),a.stopPropagation(),root.beginAutocalcOff();var g=-d.deltaY*b;if(root.lookup("touchPinchEnabled").value()){var h=root.lookup("touchPinch"),i=h.value();i+=g,h.assign(i,root.scope,Symbol.hciAgent,f)}else{var j=y.value();j=j*(e+2*g)/e,j<.05&&(j=.05),y.assign(j,root.scope,Symbol.hciAgent,f)}return void root.endAutocalcOff()}if(root.lookup("mouseWheelEnabled").value()){if(root.beginAutocalcOff(),0!==d.deltaY&&(!a.ctrlKey||a.altKey||a.metaKey||a.shiftKey)){a.preventDefault(),a.stopPropagation();var k=root.lookup("mouseWheel"),l=k.value(),g=d.deltaY*b;l+=g,k.assign(l,root.scope,Symbol.hciAgent,f),root.lookup("mouseWheelVelocity").assign(g,root.scope,Symbol.hciAgent,f)}if(0!==d.deltaX){a.preventDefault(),a.stopPropagation();var m=root.lookup("touchPanX"),n=m.value(),o=d.deltaX*b;n+=o,m.assign(n,root.scope,Symbol.hciAgent,f),root.lookup("touchPanXSpeed").assign(o,root.scope,Symbol.hciAgent,f)}root.endAutocalcOff()}}).on("mouseout",function(a){n.insideCanvas=!1;var b=root.lookup("mouseFollow").value();root.lookup("mouseZone").assign(void 0,root.scope,Symbol.hciAgent,b)}).on("mouseenter",function(a){if(!n.insideCanvas){n.insideCanvas=!0;var b;0==n.buttonCount?b="":(b="|",n.leftButton&&(b+="Left|"),n.middleButton&&(b+="Middle|"),n.rightButton&&(b+="Right|"),n.button4&&(b+="Button4|"),n.button5&&(b+="Button5|"));var c=root.lookup("mouseButtons"),d=c.value();if(b!=d){var e=root.lookup("mouseFollow").value();root.beginAutocalcOff(),c.assign(b,root.scope,Symbol.hciAgent,e),root.lookup("mouseButton").assign("Enter window",root.scope,Symbol.hciAgent,e);var f=root.lookup("mousePressed");f.value()!=n.leftButton&&f.assign(n.leftButton,root.scope,Symbol.hciAgent,e),""==d&&""!=b&&(root.lookup("mouseDown").assign(void 0,root.scope,Symbol.hciAgent,e),root.lookup("mouseDownView").assign(void 0,root.scope,Symbol.hciAgent,e)),root.endAutocalcOff()}}}).on("mousemove",function(a){k=!0;var b=root.lookup("mouseFollow").value();root.beginAutocalcOff();var d,e,f,g,i=root.lookup("mouseView"),j=root.lookup("mousePosition"),l=i.value(),m=j.value();m&&(f=m.x,g=m.y);var o=root.lookup("view_"+s+"_scale").value(),p=root.lookup("view_"+s+"_zoom").value(),q=o*p;if(n.capturing){var r=a.originalEvent;d=f+r.movementX/q,e=g+r.movementY/q}else{var t=$(this).offset();d=(a.pageX-Math.round(t.left))/q,e=(a.pageY-Math.round(t.top))/q;var u=root.lookup("view_"+s+"_offset").value();u instanceof Point&&(d-=u.x,e-=u.y)}i.assign(s,root.scope,Symbol.hciAgent,b);var v=new Point(d,e);j.assign(v,root.scope,Symbol.hciAgent,b);var w,x=Date.now();if(l==s&&void 0!==h){if(w=x-h,w>=c.mouseVelocitySampleTime){var y=root.lookup("mouseVelocity"),z=y.value(),A=1e3*(d-f)/w,B=1e3*(e-g)/w;if(z){var C=c.mouseVelocityDampening,D=z.x;(A>0&&D>0||A<0&&D<0)&&(A=C*D+(1-C)*A);var E=z.y;(B>0&&E>0||B<0&&E<0)&&(B=C*E+(1-C)*B)}A=Math.ceil(A*q)/q,B=Math.ceil(B*q)/q;var F=new Point(A,B);y.assign(F,root.scope,Symbol.hciAgent,b),h=x}}else h=x;var G,H=c.findDrawableHit(s,d,e,!1,!1);G=void 0===H?void 0:H.name;var I=root.lookup("mouseZone"),J=I.value();G!==J&&I.assign(G,root.scope,Symbol.hciAgent,b),root.endAutocalcOff()}).on("keyup",function(a){var b=a.which,c=!1;if(a.altKey&&!a.shiftKey&&!a.ctrlKey){var d=root.lookup("view_"+s+"_zoom"),e=d.value();61==b||187==b?(e=1.25*e,c=!0):173==b||189==b?(e/=1.25,c=!0):48==b&&(e=1,c=!0),d.assign(e,root.scope,Symbol.hciAgent)}c&&(a.preventDefault(),a.stopPropagation())}),{initialWidth:L,initialHeight:M,code_entry:p,offsetSym:z,zoomSym:y,widthSym:A,heightSym:B,scaleSym:x}},this.createEmbedded=function(b,d,e){var f=b;eden.execute2("view_"+f+"_content is "+e+";");var g=c.createCommon(b,d),h=(g.initialWidth,g.initialHeight,g.code_entry),i=g.offsetSym,j=g.zoomSym,k=g.widthSym,l=g.heightSym,m=g.scaleSym,n={code_entry:h,contents:h,destroy:function(){delete canvases[f],delete contents[f]},resize:function(b,d){var e,g,h=i.value();h instanceof Point?(e=h.x,g=h.y):(e=0,g=0);var n,o,p=j.value(),q=document.getElementById(f+"-canvas"),r=!1,s=k.value();if(void 0===s?(n=p>1?Math.ceil(b*p):Math.floor(b),q.width!=n&&(q.width=n,r=!0)):s=Math.ceil(s*m.value()*p+e),void 0===l.value()){if(p>1)o=Math.ceil(d*p);else{o=d,void 0!==s&&s>o&&(o-=a.scrollBarSize);var o=Math.floor(o-1)}o!=q.height&&(q.height=o,r=!0)}r&&c.drawPicture(f)}};return n},this.createDialog=function(b,d){var e,f=b.slice(0,-7),g=c.createCommon(f,d),h=g.initialWidth,j=g.initialHeight,k=g.code_entry,l=g.offsetSym,m=g.zoomSym,n=g.widthSym,o=g.heightSym,p=g.scaleSym;return $('
').html(k).dialog({appendTo:"#jseden-views",title:d,width:h+a.scrollBarSize,height:j+a.titleBarHeight,minHeight:120,minWidth:230,classes:{"ui-dialog":"canvas-dialog unpadded-dialog ui-front"}}),e={confirmClose:!0,destroy:function(){var a=i[f];for(var b in a)for(var c=a[b],d=0;d1?Math.ceil(b*k):Math.floor(b),q.width!=i&&(q.width=i,r=!0)):s=Math.ceil(s*p.value()*k+e),void 0===o.value()){if(k>1)j=Math.ceil(d*k);else{j=d,void 0!==s&&s>j&&(j-=a.scrollBarSize);var j=Math.floor(j-1)}j!=q.height&&(q.height=j,r=!0)}r&&c.drawPicture(f)}},c.drawPicture(f),e},root.lookup("mouseDownZone").addJSObserver("recordClick",function(a,b){if(eden.isValidIdentifier(b)){var c=root.lookup(b+"_click");c.value()===!1&&c.assign(!0,root.scope,Symbol.hciAgent,!0)}}),this.endClick=function(){var a=root.lookup("mouseDownZone").value();if(eden.isValidIdentifier(a)){var b=root.lookup(a+"_click");b.value()===!0&&b.assign(!1,root.scope,Symbol.hciAgent,!0)}},this.canvasNameFromElement=function(a){for(;a;){var b=a.id;if("-canvascontent"==b.slice(-14))return b.slice(0,-14);a=a.parentElement}return null},document.addEventListener("mouseup",function(b){var c=root.lookup("mouseFollow").value();if(root.beginAutocalcOff(),!n.insideCanvas){var d;switch(b.button){case 0:n.leftButton=!1,d="Left";break;case 1:n.middleButton=!1,d="Middle";break;case 2:n.rightButton=!1,d="Right";break;case 3:n.button4=!1,d="Button4";break;case 4:n.button5=!1,d="Button5";break;default:d="Unknown"}n.buttonCount=n.leftButton+n.middleButton+n.rightButton+n.button4+n.button5;var e=root.lookup("mouseButtons");if(0==n.buttonCount&&""!=e.value()){var f=root.lookup("mousePressed"),g=f.value();root.lookup("mouseButton").assign(d+" up",root.scope,Symbol.hciAgent,c),e.assign("",root.scope,Symbol.hciAgent,c),root.lookup("mousePosition").assign(void 0,root.scope,Symbol.hciAgent,c),g&&f.assign(!1,root.scope,Symbol.hciAgent,c),root.lookup("mouseUp").assign(void 0,root.scope,Symbol.hciAgent,c),root.lookup("mouseView").assign(void 0,root.scope,Symbol.hciAgent,c),a.plugins.Canvas2D.endClick()}}root.endAutocalcOff()}),document.addEventListener("mousedown",function(a){if(!n.insideCanvas){switch(a.button){case 0:n.leftButton=!0;break;case 1:n.middleButton=!0;break;case 2:n.rightButton=!0;break;case 3:n.button4=!0;break;case 4:n.button5=!0}n.buttonCount=n.leftButton+n.middleButton+n.rightButton+n.button4+n.button5}}),document.addEventListener("pointerlockchange",function(a){var b=null!==document.pointerLockElement;n.capturing=b;var c=root.lookup("mouseFollow").value();root.lookup("mouseCaptured").assign(b,root.scope,void 0,c)}),a.views.Canvas2D={dialog:this.createDialog,embedded:this.createEmbedded,title:"Canvas 2D",category:a.viewCategories.visualization,holdsContent:!0};var o;o="/index-dev.html"==document.location.pathname.slice(-15)?"canvas.js-e":"jseden-canvas.min.js-e",Eden.Selectors.execute("plugins > canvas > canvas",function(){eden.root.lookup("plugins_canvas_loaded").assign(!0,eden.root.scope),b&&b()})},EdenUI.plugins.Canvas2D.FillStyle=function(){},EdenUI.plugins.Canvas2D.Transform=function(){},EdenUI.plugins.Canvas2D.Transform.CSSInfo=function(a,b,c){this.css=a,this.scaleX=b,this.scaleY=c},EdenUI.plugins.Canvas2D.title="Canvas 2D",EdenUI.plugins.Canvas2D.description="Provides the ability to draw two-dimensional shapes, images, text and user interface controls using EDEN dependencies.",EdenUI.plugins.Page=function(a,b){function c(a){if(!a)return"";if("title"!=a[0])return"";var b,c=$("
"),d=$("
");a[6]&&c.css("height",""+a[6]+"px"),b=a[1]?$(""+a[1]+""):$('');var e=$("
"+a[2]+"");return d.append(b),d.append(e),c.append(d),void 0!==a[3],c}function d(a){if(!a)return"";if("header"!=a[0])return"";switch(a[3]){case 0:return $("

"+a[1]+"

");case 1:return $("")}}function e(a){var b=typeof a;switch(b){case"string":return a;case"number":return""+a+"px";default:return""}}function f(a,b){for(var c=0;c]*(?:"[^"]*")*(?:'[^']*')*)*)?(?:\/|(?:>((?:[^<]*(?:<(?!\/jseden\1>))*)*)<\/jseden\1))>/g,function(a,d,e,f,h,i,j){return void 0===h&&(h=""),b.push(h),c.push(g(e,f)),"\0\0"});var d=a.split("\0\0");if(1==d.length)return a;for(var e=$("
"),f=0;f"+d[f]+"
")),void 0===c[f].tagType){var h=b[f].split("\n").length;void 0===c[f].lines&&(c[f].lines=h),void 0===c[f].width&&(c[f].width="50%"),void 0===c[f].box&&(c[f].box=!0);var i=l(["script",c[f].static,[b[f]],c[f].name,c[f].box,c[f].lines,!1,c[f].float,c[f].width]);e.append(i)}else if(c[f])if("canvas"==c[f].tagType){var j=n(["canvas",c[f].name,c[f].source,c[f].width,c[f].height,c[f].float,c[f].box]);e.append(j)}else if("veden"==c[f].tagType){var k=m(["veden",c[f].name,c[f].width,c[f].height,c[f].float,b[f]]);e.append(k)}return e.append($("
"+d[d.length-1]+"
")),e.get(0)}function i(a){if(a&&"element"==a[0]){var b,c=a[1],d=a[2],e=a[3],g=a[4],i=a[5],k=a[6],l=(a[7],a[8],a[9],a[10],a[11],a[12]),m=a[13];switch(c){case"div":case"span":case"button":case"img":case"p":case"ul":case"ol":case"li":case"br":case"pre":case"h1":case"h2":case"h3":case"a":case"input":b=document.createElement(c);break;default:return void console.error("Invalid element type: "+c)}if(d&&(b.id=d),e&&(b.className=e),g&&"string"==typeof g){var n=h(g);"string"==typeof n?b.innerHTML=n:b.appendChild(n)}return g&&g instanceof Array&&j(b,g),i&&"string"==typeof i&&(b.cssText=i),i&&i instanceof Array&&f(b,i),k&&d&&(b.onclick=function(a){var b=eden.root.lookup(d+"_click");console.log("ELEMENT CLICK"),b.assign(!0,eden.root.scope)}),"img"==c&&l&&(b.src=l),"a"==c&&m&&(b.href=m),b}}function j(a,b){if("string"==typeof b[0]){var c=i(b);return void(c&&a.appendChild(c))}for(var d=0;d([\s\S]*?)<\/jseden>/g,function(a,b,d,e,f){return console.log("ATTRIBS: "+b),c.push(d),"\0\0"});var d=b.split("\0\0");if(1==d.length)return $("
"+b+"
");for(var e=$("
"+d[f]+"
"));var g=c[f].split("\n").length,h=l(["script",!1,[c[f]],void 0,!0,g,!1,!1,"50%"]);e.append(h)}return e.append($("
"+d[d.length-1]+"
")),e}function l(b){if(b&&"script"==b[0]){var c=b[1],d=b[2],e=b[3],f=b[4],g=b[5],h=b[6],i=b[7],j=b[8];if(void 0===e&&(e="embedded"+B,B++),c){var k;k=f?$("
"):$("
");var l,m=new EdenUI.Highlight(k.get(0));l=d instanceof Array?EdenUI.plugins.ScriptInput.buildScriptFromList(d):d;var n=new Eden.AST(l);m.highlight(n,-1,-1),i&&"none"!=i&&k.css("float",i),"50%"!=j&&("number"==typeof j?k.width(j):k.css("width",j));var o=EdenUI.plugins.ScriptInput.getRequiredHeight(g,!0);return k.height(o),k}var p;z[e]?(p=z[e],p.update(d)):(p=a.views.ScriptInput.embed(e,e,d,h),z[e]=p);var q;q=f?$("
"):$("
");var o=EdenUI.plugins.ScriptInput.getRequiredHeight(g,!0);return q.height(o),i&&"none"!=i&&q.css("float",i),"50%"!=j&&("number"==typeof j?q.width(j):q.css("width",j)),p.contents.appendTo(q),q.resizable(),q}}function m(b){if(b&&"veden"==b[0]){var c,d=b[1],e=b[2],f=b[3],g=b[4],h=b[5];A[d]?c=A[d]:(c=a.views.Veden.embed(d,d,h),A[d]=c);var i;return i=$("
"),i.height(f),g&&"none"!=g&&i.css("float",g),"50%"!=e&&("number"==typeof e?i.width(e):i.css("width",e)),c.contents.appendTo(i),i.resizable(),i}}function n(b){var c,d=b[6],f=b[3],g=b[4];if(c=d?$("
"):$("
"),f&&c.css("width",e(f)),g&&c.css("height",e(g)),void 0===y[b[1]]){var h=a.views.Canvas2D.embedded(b[1],b[1],b[2]);y[b[1]]=h,c.append(h.code_entry),x.push(function(){h.resize(b[3],b[4])})}else y[b[1]].code_entry.appendTo(c),x.push(function(){y[b[1]].resize(b[3],b[4])});return"none"!=b[5]&&c.css("float",b[5]),c}function o(a){var b;if(b=a[1]?$("
    "):$("
      "),a[2]&&a[2]instanceof Array)for(var c=0;c"+a[2][c]+"");b.append(d)}return b}function p(a,b){if(!a)return"";if(!(a instanceof Array))return"";for(var c=$("
      "),e=0;e"));break;case"list":c.append(o(a[e]))}return c}function q(a,b){if(void 0!==b&&b instanceof Array){for(var c in y)y[c].code_entry.detach();for(var d in z)z[d].contents.detach();w.html(""),j(w.get(0),b);for(var e=0;e");$("#jseden-views").append(w).addClass("page-body");var x=[],y={},z={},A={},B=0,C=["top","bottom","left","right","width","height","background","position","color","border","font","fontSize","fontFamily","fontWeight","borderBottom","borderLeft","borderRight","borderTop","overflow","padding","paddingTop","paddingLeft","paddingRight","paddingBottom","margin","marginLeft","marginRight","marginTop","marginBottom","textShadow"];r(t,v),t.addJSObserver("pageGenerator",r),u.addJSObserver("pageGenerator",q),Eden.Selectors.execute("plugins > page > page",function(){eden.root.lookup("plugins_page_loaded").assign(!0,eden.root.scope),b&&b()})},EdenUI.plugins.Page.title="Page",EdenUI.plugins.Page.description="Generate web content from scripts.";var edenfunctions={};EdenUI.plugins.SymbolViewer=function(a,b){var c=this;this.instances=[];var d=0,e=function(a,b){var c='\t\t\t
      \t\t\t\t \t\t\t\tEdit Listed
      \t\t\t\t';return c+='\t\t\t
      \t\t\t
      '};this.createDialog=function(b,f,g){function h(){var b=q.value();return o.val().startsWith("select: ")?a.regExpFromStr("","",!1,b):a.regExpFromStr(o,"",!1,b)}function i(a,b){n.search(p.value,h()),"regexp"==b?o.attr("placeholder","search regular expression"):"simple"==b?o.attr("placeholder","simple search"):o.attr("placeholder","search")}var k=b.slice(0,-7),l=root.lookup("createView"),m=$('
      ');m.html(e(b,g));var n=new EdenUI.plugins.SymbolViewer.SymbolList(a.eden.root,m.find(".symbollist-results")[0],g);$dialog=$('
      ').append(m).dialog({appendTo:"#jseden-views",title:f,width:360,height:400,minHeight:200,minWidth:200,classes:{"ui-dialog":"symbollist-dialog ui-front"}}),c.instances.push(n),d++,1==d&&a.eden.root.addGlobal(j),m.find(".symbollist-search-box-outer > .symbollist-edit").click(function(){var b="edit_"+k;if(p.value.startsWith("select: ")){a.createView(b,"ScriptInput",void 0);var c=eden.root.lookup("view_"+b+"_tabs").value();Array.isArray(c)||(c=[]),c.push(p.value.substring(8)),eden.root.lookup("view_"+b+"_tabs").assign(c,eden.root.scope,Symbol.hciAgent),eden.root.lookup("view_"+b+"_current").assign(c.length-1,eden.root.scope,Symbol.hciAgent)}});var o=m.find(".symbollist-search-box-outer > .symbollist-search"),p=o[0],q=root.lookup("view_"+k+"_search_language");i(q,q.value()),q.addJSObserver("refreshView",i);var r=root.lookup("view_"+k+"_search_string"),s=function(a,b){void 0!==b&&(b!==p.value&&(p.value=b),n.search(b,h()))},t=r.value();void 0===t?(r.assign("",root.scope,l),n.search("",new RegExp(""))):s(r,t),r.addJSObserver("refreshView",s),o.keyup(function(){r.assign(p.value,root.scope,Symbol.hciAgent)});var u={destroy:function(){var b=c.instances.indexOf(n);c.instances.splice(b,1),d--,0==d&&a.eden.root.removeGlobal(j)}};return u},this.createObservableDialog=function(a,b){return c.createDialog(a,b,"obs")},this.createFunctionDialog=function(a,b){return c.createDialog(a,b,"func")},this.createAgentDialog=function(a,b){return c.createDialog(a,b,"agent")},this.createSymbolDialog=function(a,b){return c.createDialog(a,b,"all")};var f={},g={},h=!1;this.isCreationPending=function(a){return a in g},this.delay=40;var i=function(){for(x in c.instances){var a,b,d,e=c.instances[x];void 0===EdenUI.plugins.SymbolViewer.inlineEditorSymbol&&(a=$(e.symresults),b=a.parent(),d=a.scrollTop(),a.detach());for(var i in g){var j=g[i];e.filter?e.filter.indexOf(i)>=0&&e.addSymbol(j,i):e.addSymbol(j,i)}for(var i in f)e.updateSymbol(i);void 0===EdenUI.plugins.SymbolViewer.inlineEditorSymbol&&(a.appendTo(b),a.scrollTop(d))}f={},g={},h=!1},j=function(a,b){var d=a.name;if(1==b)g[d]=a;else{if(d in g)return;f[d]=a}h||(h=!0,setTimeout(i,c.delay))};a.views.ObservableList={dialog:this.createObservableDialog,title:"Observable List",category:a.viewCategories.comprehension,menuPriority:0},a.views.FunctionList={dialog:this.createFunctionDialog,title:"Function List",category:a.viewCategories.comprehension,menuPriority:0},a.views.AgentList={dialog:this.createAgentDialog,title:"Agent List",category:a.viewCategories.comprehension,menuPriority:0},a.views.SymbolList={dialog:this.createSymbolDialog,title:"Symbol List",category:a.viewCategories.comprehension,menuPriority:1},eden.root.lookup("plugins_symbolviewer_loaded").assign(!0,eden.root.scope),b()},EdenUI.plugins.SymbolViewer.title="Symbol Viewer",EdenUI.plugins.SymbolViewer.description="Provide various views of the symbol table.",EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0,EdenUI.plugins.SymbolViewer.SymbolList=function(a,b,c){this.root=a,this.regExp=new RegExp(""),this.type=c,this.category="all",this.customCategory=!1,this.subtypes="all",this.symresults=b,this.symbols={},this.filter=void 0},EdenUI.plugins.SymbolViewer.SymbolList.prototype.search=function(a,b,c,d){if("undefined"!=typeof a)if(a.startsWith("select: ")){var e=Eden.Selectors.query(a.substr(8),"symbol");console.log(e),this.filter=e,this.regExp=b,this.regExp=b,void 0!==d&&(this.subtypes=d),EdenUI.closeTooltip(),this.symresults.innerHTML="",this.symbols={};for(var f=0;f'),d&&this.element.addClass("symbollist-"+d+"-result"),c){case"func":this.update=this.updateFunction;break;case"agent":this.update=this.updateProcedure;break;case"obs":this.update=this.updateObservable}var f=this,g=!1;this.element.click(function(){EdenUI.plugins.SymbolViewer.inlineEditorSymbol||g||(g=!0,setTimeout(function(){if(!EdenUI.plugins.SymbolViewer.inlineEditorSymbol&&g){g=!1;"edit_"+f.name;Eden.Selectors.goto("> :not(ACTIVE) >> "+a.name)}},350))}),"obs"==c&&this.element.dblclick(function(){function a(){var a=l.get(0).value,b=o.value;";"!=b.slice(-1)&&(b+=";"),eden.execute2(f.name+" "+a+" "+b),e(),EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0}function c(b){var c=b.which;13==c?a():27==c&&(e(),EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0)}if(g=!1,EdenUI.plugins.SymbolViewer.inlineEditorSymbol!==f){var d=f.symbol.cache.value;if(void 0!==f.symbol.definition||"boolean"!=typeof d){EdenUI.plugins.SymbolViewer.inlineEditorSymbol=f,f.element.addClass("symbollist-inline-editor");var h=f.element.find(".result_value"),i=f.element.find(".result_separator");h.html("");var j,k;void 0!==f.symbol.definition?(j=f.symbol.getSource().replace(new RegExp("^\\s*"+b+"\\s+is\\s+"),""),k="is"):(j=Eden.edenCodeForValue(d),k="=");var l=$("");"="==k?(l.append(''),l.append('')):(l.append(''),l.append('')),i.html(" "),i.append(l);var m=Eden.htmlEscape(j,!0),n=$(''),o=n.get(0);n.on("keyup",c),n.on("blur",function(){setTimeout(function(){l.is(document.activeElement)||(e(),setTimeout(function(){EdenUI.plugins.SymbolViewer.inlineEditorSymbol===f&&(EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0)},500))},0)}),l.on("keydown",c),l.on("blur",function(){setTimeout(function(){n.is(document.activeElement)||(e(),setTimeout(function(){EdenUI.plugins.SymbolViewer.inlineEditorSymbol===f&&(EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0)},500))},0)}),h.append(n);var p=f.element.find(".symbollist-result-inner");p.length>0&&(p.get(0).onmouseenter=void 0),EdenUI.closeTooltip(),o.focus(),o.select();var q=j.slice(0,1);'"'!=q&&"'"!=q&&"["!=q&&"{"!=q||(o.selectionStart=1,o.selectionEnd=j.length-1)}else d===!0?f.symbol.assign(!1,eden.root.scope,Symbol.hciAgent,!0):f.symbol.assign(!0,eden.root.scope,Symbol.hciAgent,!0)}}),this.update()},EdenUI.plugins.SymbolViewer.Symbol.prototype.updateFunction=function(){var a,b,c=this.symbol.getSource();if(a=void 0===this.symbol.definition||/^func\s/.test(c)?this.name:""+this.name+"",void 0!=edenfunctions.functions&&void 0!==edenfunctions.functions[this.name]){this.details=edenfunctions.functions[this.name];var d=Object.keys(this.details.parameters||{});b="( "+d.join(", ")+" )"}else b="";var e=""+a+""+b;if(void 0!==this.symbol.definition&&!/^func\s/.test(this.symbol.eden_definition)){var f=Eden.htmlEscape(c,!1,!0);f=Eden.htmlEscape("
      "+f+";
      "),e=""+e+""}this.element.html(e)},EdenUI.plugins.SymbolViewer.Symbol.prototype.updateObservable=function(){var a,b=this.symbol.value(),c=_formatVal(b);a=void 0!==this.symbol.definition?""+this.name+"":this.name;var d=""+a+" = "+c+"";if(void 0!==this.symbol.definition){var e=Eden.htmlEscape(this.symbol.getSource(),!1,!0);e=Eden.htmlEscape("
      "+e+";
      "),d=""+d+""}this.element.html(d)},EdenUI.plugins.SymbolViewer.Symbol.prototype.updateProcedure=function(){var a,b,c=this.symbol.getSource();if(a=void 0===this.symbol.definition||/^proc\s/.test(c)?this.name:""+this.name+"",void 0!=edenfunctions.functions&&void 0!==edenfunctions.procedures[this.name]){this.details=edenfunctions.procedures[this.name];var d=Object.keys(this.details.parameters||{});b="( "+d.join(", ")+" )"}else b="";var e=""+a+""+b;if(void 0!==this.symbol.definition&&!/^proc\s/.test(c)){var f=Eden.htmlEscape(c,!1,!0);f=Eden.htmlEscape("
      "+f+";
      "),e=""+e+""}this.element.html(e)};var edenfunctions={};EdenUI.plugins.VersionViewer=function(a,b){var c=this;this.instances=[];var d=0,e=function(a,b){var c='
      ';return c};this.createDialog=function(b,f,g){var h=b.slice(0,-7),i=(root.lookup("createView"),$('
      '));i.html(e(b,g)),$dialog=$('
      ').append(i).dialog({appendTo:"#jseden-views",title:f,width:360,height:400,minHeight:200,minWidth:200,classes:{"ui-dialog":"versionviewer-dialog ui-front"}});var j=(root.lookup("view_"+h+"_search_string"),function(){var a=URLUtil.getParameterByName("load");$.get(Eden.DB.remoteURL+"/project/versions",{projectID:a},function(b){var c=i.find(".version-viewer-list").html(""),d=$("VidDateParentDiff");c.append(d),$(b).each(function(b,d){var e=$(''+d.saveID+""+d.date+""+d.parentDiff+"");c.append(e)})})});j();var k={destroy:function(){var b=c.instances.indexOf(symbollist);c.instances.splice(b,1),d--,0==d&&a.eden.root.removeGlobal(symbolChanged)}};return k},this.createVersionListDialog=function(a,b){return c.createDialog(a,b,"all")},a.views.VersionList={dialog:this.createVersionListDialog,title:"Version List",category:a.viewCategories.history,menuPriority:1},eden.root.lookup("plugins_VersionViewer_loaded").assign(!0,eden.root.scope),b()},EdenUI.plugins.VersionViewer.title="Version Viewer",EdenUI.plugins.VersionViewer.description="Show version details for a specified project.",EdenUI.plugins.VersionViewer.inlineEditorSymbol=void 0,EdenUI.plugins.ExternalHTMLContent=function(a,b){function c(){d=!1}var d=!1,e=!1;this.createDialog=function(b,f){function g(a,b){void 0===b?n.src="plugins/external-html-content/undefined-url.html?view="+encodeURI(j):n.src="plugins/external-html-content/redirect.html?view="+encodeURI(j)+"&url="+encodeURI(b)}function h(a,b){b?(r.value()&&l.addClass("external-html-content-pinned"),p.css("display","block")):(l.removeClass("external-html-content-pinned"), -p.css("display","none"))}function i(a,b){q.value()&&l.toggleClass("external-html-content-pinned",b)}e||(""==document.location.hash&&window.history.pushState({},"","#noNavigateAway"),window.addEventListener("popstate",function(){""==document.location.hash&&(d?window.history.forward(1):a.modalDialog("Leave Environment?","

      Leaving this page will discard the current script. Your work will not be saved.

      Are you sure you want to close JS-EDEN?

      ",["Close JS-EDEN","Return to Construal"],1,function(a){0==a?(doingNavigateAway=!0,window.history.back(1)):window.history.forward(1)}))}),e=!0);var j=b.slice(0,-7),k=root.lookup("createView"),l=$(''),m=root.lookup("_view_"+j+"_url"),n=l[0];g(m,m.value()),m.addJSObserver("refreshView",g);var o=$('
      ').html(l).dialog({title:f,width:600,height:450,minHeight:120,minWidth:230,dialogClass:"external-html-content"}),p=$('
      ');o.append(p);var q=root.lookup("_view_"+j+"_toolbar_visible"),r=root.lookup("_view_"+j+"_toolbar_pinned");void 0===q.value()&&q.assign(!0,root.scope,k),void 0===r.value()&&r.assign(!1,root.scope,k),h(q,q.value()),q.addJSObserver("refreshView",h),r.addJSObserver("refreshView",i);var s=$('');s.on("click",function(){r.assign(!r.value(),root.scope,Symbol.hciAgent),n.focus()}),p.append(s);var t=$('');t.on("click",function(){d||setTimeout(c,1e3),d=!0,window.history.back(1),n.focus()}),p.append(t);var u=$('');u.on("click",function(){window.history.forward(1),n.focus()}),p.append(u);var v=$('');return v.on("click",function(){g(m,m.value()),n.focus()}),p.append(v),{confirmClose:!0}},a.views.ExternalHTMLContent={dialog:this.createDialog,title:"External HTML Content",category:a.viewCategories.visualization,holdsContent:!0},a.eden.include("plugins/external-html-content/external-html-content.js-e",b)},EdenUI.plugins.ExternalHTMLContent.title="External HTML Content",EdenUI.plugins.ExternalHTMLContent.description="Allows construals to display web pages created outside of JS-EDEN.",EdenUI.plugins.HTMLContent=function(a,b){this.createDialog=function(a,b){function c(a){return"view_"+e+"_"+a}function d(a,b){k.get(0).parentNode.style.background=b}var e=a.slice(0,-7),f=[c("background_colour"),c("content")],g=$('
      ');g.on("mousedown","button",function(a){var b=a.currentTarget.name,c=a.currentTarget.getAttribute("data-value");null!==c&&null!==c.charAt(0).match(/[0-9]?/)&&(c=parseInt(c)),eden.root.lookup(b).assign(null===c||c,eden.root.scope,Symbol.hciAgent)}),g.on("mouseup","button",function(a){var b=a.currentTarget.name,c=a.currentTarget.getAttribute("data-value");null===c&&eden.root.lookup(b).assign(!1,eden.root.scope,Symbol.hciAgent)}),g.on("click",function(a){var b=a.srcElement.getAttribute("data-jseden");b&&""!=b&&(console.log(b),eden.execute2(b,{name:"execute"}))});var h=root.lookup("view_"+e+"_content"),i=function(a,b){void 0===b?g.html('
      Give view_'+e+"_content a value to display HTML formatted text here.
      "):g.html(b)};i(h,h.value()),h.addJSObserver("repaintView",i);var j=root.lookup("view_"+e+"_background_colour");j.addJSObserver("changeColour",d);var k=$('
      ').html(g).dialog({appendTo:"#jseden-views",title:b,width:600,height:450,minHeight:120,minWidth:230,classes:{"ui-dialog":"htmlviews-dialog ui-front"}}),l=j.value();return l&&d(j,l),{confirmClose:!0}},a.views.HTMLContent={dialog:this.createDialog,title:"HTML Content",category:a.viewCategories.visualization,holdsContent:!0},Eden.Selectors.execute("plugins > html > html",function(){eden.root.lookup("plugins_html_loaded").assign(!0,eden.root.scope,Symbol.localJSAgent),b&&b()})},EdenUI.plugins.HTMLContent.title="HTML Content",EdenUI.plugins.HTMLContent.description="Provides construals with the ability to create windows dedicated to displaying HTML content created using EDEN code.",EdenUI.plugins.ExpressionTree=function(a,b){var c=this;this.createDialog=function(a,b){var c='
      ';$dialog=$('
      ').html(c).dialog({title:b,width:300,height:450,minHeight:120,minWidth:230})};var d=function(a,b,c,d,e){var f=function(g,h,i){if(!g.hasOwnProperty("children"))return g.name;var j,k,l,m=g.name,n=g.children;if(b.hasOwnProperty(m)&&2==n.length){j=b[m],k=j.precedence;var o=j.associativity,p=f(n[0],k,j.text),q=f(n[1],k,j.text);if("left"==o){var r=n[1].name;n[1].hasOwnProperty("children")&&2==n[1].children.length&&b.hasOwnProperty(r)&&k==b[r].precedence&&(q="("+q+")")}else{var s=n[0].name;n[0].hasOwnProperty("children")&&2==n[0].children.length&&b.hasOwnProperty(s)&&k==b[s].precedence&&(p="("+p+")")}l=j.whitespace?p+" "+j.text+" "+q:p+j.text+q}else if(a.hasOwnProperty(m))j=a[m],k=j.precedence,l=j.text+f(n[0],k,j.text);else if(c.hasOwnProperty(m))j=c[m],k=j.precedence,l=f(n[0],k,j.text)+j.text;else if(d.hasOwnProperty(m))j=d[m],this.precedence=j.precedence,l=j.code(n,i);else{k=e;for(var t=[],u=0;u"]={precedence:6,associativity:"left",text:">=",whitespace:!0},e[">="]={precedence:6,associativity:"left",text:">",whitespace:!0},e["=~"]={precedence:6,associativity:"left",text:"=~",whitespace:!0},e["!~"]={precedence:6,associativity:"left",text:"!=",whitespace:!0},e["//"]={precedence:7,associativity:"left",text:"//",whitespace:!0},e["+"]={precedence:8,associativity:"left",text:"+",whitespace:!0},e["-"]={precedence:8,associativity:"left",text:"-",whitespace:!0},e["*"]={precedence:9,associativity:"left",text:"*",whitespace:!0},e["/"]={precedence:9,associativity:"left",text:"/",whitespace:!0},e["%"]={precedence:9,associativity:"left",text:"%",whitespace:!0},e["^"]={precedence:11,associativity:"right",text:".",whitespace:!1},e["."]={precedence:14,associativity:"left",text:".",whitespace:!1};var f={};f["-"]={precedence:10,text:"-"},f["!"]={precedence:10,text:"!"},f["&"]={precedence:10,text:"&"},f.not={precedence:10,text:"!"},f["++."]={precedence:11,text:"++"},f["--."]={precedence:11,text:"--"},f["*"]={precedence:12,text:"*"};var g={};g["#"]={precedence:11,text:"#"},g[".++"]={precedence:11,text:"++"},g[".--"]={precedence:11,text:"--"};var h={},i=13;this.convertTreeToEden=d(f,e,g,h,i),h["?"]={precedence:2,code:function(a){var b=c.convertTreeToEden(a[0]),d=c.convertTreeToEden(a[1]),e=c.convertTreeToEden(a[2]);return b+"? "+d+" : "+e}},h["`...`"]={precedence:13,code:function(a){var b=c.convertTreeToEden(a[0]);return"`"+b+"`"}},h["${{...}}$"]={precedence:13,code:function(a){var b=a[0].name;return"${{ "+b+" }}$"}},h["(...)"]={precedence:13,code:function(a){for(var b=c.convertTreeToEden(a[0]),d=[],e=1;e'+c(a)+"
      "),$dialog=$('
      ').html(code_entry).dialog({title:b,width:600,height:450,minHeight:120,minWidth:230})},a.views.SymbolLookUpTable={dialog:this.createDialog,title:"Symbol Look-Up Table",category:a.viewCategories.comprehension,menuPriority:3},this.search=function(b){var c=$("#"+b+"-regexp"),e=a.regExpFromStr(c);document.getElementById(b+"-table-div").innerHTML=d(e,b)};var c=function(a){var b="",c="
      "+b+"
      "+d(new RegExp(""),a)+"
      ";return c},d=function(a,b){var c='NameTypeDefinitionCurrent ValueWatchesUpdatesBackticksLast Modified ByJavaScript Actions';tableBodyHTML="";var d,h=[],i={};for(var j in root.symbols)if(d=root.symbols[j],a.test(j)){var k,l,m;if(void 0===d.eden_definition)l="-",k="function"==typeof d.cache.value?"Function":"Observable",m=Eden.htmlEscape(Eden.edenCodeForValue(d.cache.value));else if(l=Eden.htmlEscape(d.eden_definition),0==l.indexOf("proc")){if(Eden.isitSystemAgent(j)&&!new RegExp("\\b"+j+"\\b").test(a.source))continue;k="Agent",m=""}else if(0==l.indexOf("func")){if(Eden.isitSystemFunction(j)&&!new RegExp("\\b"+j+"\\b").test(a.source))continue;k="Function",m=""}else k="Dependency",m=Eden.htmlEscape(Eden.edenCodeForValue(d.cache.value));h.push([d,j,k,l,m]),i[j]=!0}for(var n=0;n

      '+o[1]+'

      '+o[2]+'

      '+o[3]+'

      '+o[4]+'

      '+r+'

      '+u+'

      '+v+'

      '+w+'

      '+x+"

      ";/^((_view_.*)|mousePosition|mouseView)$/.test(o[1])?tableBodyHTML+=y:tableBodyHTML=y+tableBodyHTML}return""+c+tableBodyHTML+"
      "},e=function(a,b,c){var d=[];for(var e in a){var f=e.slice(1);d.push(g(f,b,c))}return d.join(", ")},f=function(a,b,c){for(var d=[],e=0;e"+a+"
      ":""+a+""};this.addSymbolToSearch=function(b,c){var d,e=document.getElementById(b+"-regexp");d="false"==a.getOptionValue("optSimpleWildcards")?e.value+"|^"+c+"$":e.value+" "+Language.ui.search.disjunction+" "+c,e.value=d,this.search(b)},this.jump=function(a){var b=location.href;location.href="#"+a,history.replaceState(null,null,b)},b()},EdenUI.plugins.SymbolLookUpTable.title="Symbol Look-Up Table",EdenUI.plugins.SymbolLookUpTable.description="Displays detailed information about symbols.",EdenUI.plugins.SymbolLookUpTable.originalAuthor="Joe Butler";var edenfunctions={};SymbolMeta=function(a){this.symbol=a,this.interestingness=0,this.significance=.5,this.index=0,this.isinteresting=!1,this.oldstr=""},SymbolMeta.DependencyComplexityRate=.4,SymbolMeta.DependencyChangeProbability=.01,SymbolMeta.SubscriberRate=.1,SymbolMeta.DecayRate=.9999,SymbolMeta.DependencyPercentage=.5,SymbolMeta.SubscriberPercentage=.5,SymbolMeta.SigDeleteRate=.1,SymbolMeta.SigInterestingRate=1.01,SymbolMeta.prototype.dependencyInterestingness=function(a){var b=0,c=0,d=.1;for(var e in this.symbol.dependencies){b++,d+=(1-d)*SymbolMeta.DependencyComplexityRate;var f=e.substr(1);void 0!==a.meta[f]&&a.meta[f].interestingness>=a.minInteresting()&&c++}return d-=b*SymbolMeta.DependencyChangeProbability,0!=b&&(d=.5*d+.5*(c/b)),d<0?0:d},SymbolMeta.prototype.subscriberInterestingness=function(a){var b=0,c=0,d=0;for(var e in this.symbol.subscribers){b++,d+=(1-d)*SymbolMeta.SubscriberRate;var f=e.substr(1);void 0!==a.meta[f]&&a.meta[f].interestingness>=a.minInteresting()&&c++}return d=1-d,0!=b&&(d=.5*d+.5*(c/b)),d},SymbolMeta.prototype.nameInterestingness=function(){var a=this.symbol.name.substr(1);return"_"==a[0]?.5:/\d/.test(a)?.9:1},SymbolMeta.prototype.frequencyInterestingness=function(){},SymbolMeta.prototype.update=function(a){var b=0;b=this.dependencyInterestingness(a)*this.subscriberInterestingness(a)*this.nameInterestingness()*this.significance,this.interestingness=b},EdenUI.plugins.ObservableMining=function(a,b){var c=this;this.meta={},this.interesting=[],this.limitInteresting=15,this.symresults=void 0,this.symbolsui=[];var d=function(a){var b='
      ';return b};this.createDialog=function(a,b){var e=(a.slice(0,-7),$("
      "));e.html(d(a)),c.symresults=e.find(".symbolframer-results")[0],$dialog=$('
      ').html(e).dialog({title:b,width:360,height:400,minHeight:200,minWidth:200,dialogClass:"unpadded-dialog"})},this.delay=100;var e=void 0,f=function(){if(void 0!==c.symresults){var a=$(c.symresults).parent();$(c.symresults).detach();for(var b=0;b=c.minInteresting())){c.interesting.length;if(c.interesting.length==c.limitInteresting){var g=c.interesting[c.interesting.length-1];g.isinteresting=!1,c.interesting.pop()}c.interesting.push(e),e.isinteresting=!0,e.significance*=SymbolMeta.SigInterestingRate,c.interesting.sort(function(a,b){return b.interestingness-a.interestingness})}}},a.eden.root.addGlobal(e),a.views.ObservableMining={dialog:this.createDialog,title:"Observable Mining",category:a.viewCategories.comprehension,menuPriority:1},$(document).tooltip(),b()},EdenUI.plugins.ObservableMining.prototype.minInteresting=function(){return this.interesting.length>0?this.interesting[this.interesting.length-1].interestingness:0},EdenUI.plugins.ObservableMining.prototype.maxInteresting=function(){return this.interesting.length>0?this.interesting[0].interestingness:0},EdenUI.plugins.ObservableMining.title="Observable Mining",EdenUI.plugins.ObservableMining.description="Automatically generate search for interesting observables",EdenUI.plugins.ObservableMining.Symbol=function(){this.symbol=void 0,this.name=void 0,this.meta=void 0,this.element=$('
      '),this.details=void 0,this.update=void 0,this.outofdate=!1,this.dodelete=!1,this.symbolChanged=void 0,this.editing=!1,this.update=this.updateObservable;var a=this;this.element.hover(function(){$(this).animate({backgroundColor:"#eaeaea"},100)},function(){$(this).animate({backgroundColor:"#fafafa"},100),1==a.editing&&(a.editing=!1,a.element.find("textarea").remove(),a.element.animate({height:"20px"},"fast"))}).click(function(){if(!a.editing){var b;b="function"==typeof a.symbol.value()&&void 0!==a.symbol.eden_definition?a.symbol.eden_definition:a.symbol.definition?a.symbol.eden_definition+";":a.name+" = "+Eden.edenCodeForValue(a.symbol.value())+";",a.element.animate({height:"60px"},{duration:200,complete:function(){var c=$('');c.val(b),c.appendTo(a.element),c.show("fast")}}),a.editing=!0}}).draggable({distance:40,axis:"x",scroll:!1,drag:function(b,c){c.position.left>150?a.dodelete=!0:a.dodelete=!1},revert:function(b,c){return!a.dodelete},stop:function(b,c){a.dodelete&&(a.meta.significance*=SymbolMeta.SigDeleteRate,a.symbolChanged(a.symbol,!1),a.element.hide("drop",{direction:"right"},"slow",function(){a.element.remove()}))}})},EdenUI.plugins.ObservableMining.Symbol.prototype.updateObservable=function(a,b){if(void 0!==this.symbol){0==b&&(b=1);var c,d=(this.meta.interestingness-a)*(1/(b-a)),e=Math.round(8+12*d),f=this.symbol.value(),g=_formatFramerVal(f);c=void 0!==this.symbol.definition?""+this.name+"":this.name;var h=""+c+" = "+g+"";if(void 0!==this.symbol.definition){var i=Eden.htmlEscape(this.symbol.eden_definition,!1,!0);i=Eden.htmlEscape("
      "+i+";
      "),h=""+h+""}var j=this.element.find(".observable");j.html(h),j.css({"font-size":e+"px"})}},EdenUI.plugins.ObservablePalette=function(a,b){function c(a){var b=a.value();return"function"!=typeof b||!/\breturn\s+([^\/;]|(\/[^\/*]))/.test(b.toString())}function d(a,b){var d=a.term,e=i[d];if(void 0===e){var f=new RegExp("^"+d);e=[];for(var g in root.symbols)f.test(g)&&c(root.symbols[g])&&e.push(g);i[d]=e}b(e)}function e(){var a=h;return h++,a}function f(b,c,d,g,h,i){function j(a){var b=a.target.value;if("hide"==b)return void h.remove(c,g,d);var e;"boolean"==b?e=!1:"number"==b?e=0:"string"==b&&(e=""),o.assign(e,Symbol.hciAgent,!0)}function k(a){pa.fadeOut(250,"linear",function(){a?(pa.html("true"),pa.css("color","green")):(pa.html("false"),pa.css("color","red")),pa.fadeIn(400,"swing",function(){y.html(a?"true":"false")})})}var l=128;g?(g.hasClass("ui-accordion")&&g.accordion("destroy"),g.html("")):(g=$('
      '),i&&g.data("editor","read-only"));var m,n=a.eden.root,o=n.lookup(c),p=o.value(),q=typeof p,r="string"==q,s=!i||r,t=o.eden_definition;if(!i&&void 0!==o.eden_definition){var u=t.match(/^\S+\s+is\s+(.*?);?$/);rhs=u[1],q="definition"}var v=$('

      '+c+"

      ");i&&g.addClass("observable-palette-dependency-value-box");var w=$('
      ');v.append(w),g.append(v);var x=Eden.prettyPrintValue("",p,l,!1,!1),y=$(""+x+"");w.append(y);var z=$("");i?z.append('"):(z.append(''),z.append(''),z.append(''),z.append('')),z.append(''),z[0].value=q,z.on("change",j),w.on("click",function(a){a.stopPropagation()}),y.on("click",function(a){y.detach(),w.append(z),z.focus()}),z.on("blur",function(a){z.detach(),w.append(y)});var A=$("
      ");if("definition"==q){var B=$('
      ');B.append(c+" is "),rhsSpan=$(''),rhsSpan.append(Eden.htmlEscape(rhs)),B.append(rhsSpan),B.append(";"),B.on("click",function(a){rhsSpan.focus(),B.addClass("focussed")}),rhsSpan.on("blur",function(a){B.removeClass("focussed")}),A.append(B);var C=$('
      ');A.append(C);var D=$('Expand');D.click(function(){H.find(".observable-palette-obs-box.ui-accordion").accordion("option","active",0)});var E=$('Collapse');E.click(function(){H.find(".observable-palette-obs-box.ui-accordion").accordion("option","active",!1)});var F=$('Hide');F.click(function(){var a=H.find(".observable-palette-obs-box");a.removeClass("observable-palette-visible"),a.slideUp()});var G=$('Show');G.click(function(){var a=H.find(".observable-palette-obs-box");a.addClass("observable-palette-visible"),a.slideDown()}),C.append(D),C.append(E),C.append(F),C.append(G);var H=$('
      ');H.sortable({connectWith:".observable-palette-column",forcePlaceholderSize:!0,handle:"h3",items:">.observable-palette-obs-box",placeholder:"observable-palette-drag-placeholder",tolerance:"pointer",receive:function(a,b){var d=b.item,e=d.data("observable");(!o.isDependentOn("/"+e)||e==c&&"read-only"!=d.data("editor"))&&b.sender.sortable("cancel"),2==H.children(".observable-palette-visible").length&&C.slideDown(),h.removeDuplicates(a.target,d)},remove:function(a,b){H.children(".observable-palette-visible").length<2&&C.slideUp()}});var I,J=0;for(var K in o.dependencies){var L=o.dependencies[K];K=K.slice(1),void 0===L.eden_definition&&(I=f(b,K,e(),void 0,h,!1),h.register(K,I),H.append(I),J++)}if(J<2&&C.hide(),m=function(a,e){var i=a.eden_definition;void 0===i?f(b,c,d,g,h,!1):y.html(Eden.prettyPrintValue("",e,l,!1,!1))},A.append(H),r){var M=f(b,c,e(),void 0,h,!0);H.append(M)}}else if("number"==q){var N,O,P;if(P=1==p||p==-1||p!=Math.floor(p)?5e-4:1,0==p)N=0,O=10;else if(p>=-1&&p<=1)N=p>0?0:-1,O=1;else if(p<0){N=2*p;var Q=Number((-p%P).toPrecision(14));0!=Q&&Q!=P&&(N=N+Q-P),O=N+2*(p-N)}else N=0, -O=2*Math.ceil((p/P).toPrecision(16))*P;var R=$(''),S=R[0];R.on("input",function(a){o.assign(parseFloat(S.value),Symbol.hciAgent,!0)});var T=$('
      '),U=$("");T.append(U);var V=$('');V.append(R),U.append(V);var W=$('');T.append(W);var X=$(''),Y=$(''),Z=Y[0];X.append(Y),W.append(X),Y.on("input",function(a){var b=a.target.value;if(""!=b){var c=parseFloat(b);S.min=b;var d=o.value();c>=0&&d0?c+Math.ceil((c/e).toPrecision(16))*e:Math.ceil((c/2/e).toPrecision(16))*e,f');W.append(ca);var da=$('
      ');ca.append(da);var ea=$('');da.append(ea);var fa=$(''),ga=fa[0];ea.append(fa),fa.on("input",function(a){var b=a.target.value;""!=b&&(S.value=b,o.assign(parseFloat(b),Symbol.hciAgent,!0))}),fa.on("focus",function(a){ba=!0,aa=a.target.value}),fa.on("blur",function(a){var b=a.target.value;if(""==b)o.assign(parseFloat(aa),Symbol.hciAgent,!0);else{var c=o.value(),d=parseFloat(S.min);c'),ia=$(''),ja=ia[0];ha.append(ia),W.append(ha),ia.on("input",function(a){S.max=a.target.value});var ka=$('');da.append(ka);var la=$(''),ma=la[0];ma.acceptedValue=P,ka.append(la),la.on("input",function(a){var b=parseFloat(ma.value);if(b>0){var c,d=Math.floor(b);if(b==d){var e=String(b).match(/(0*)$/);c=Math.pow(10,e[1].length)}else c=Math.pow(10,-((b-d).toPrecision(15).replace(/0*$/,"").length-2));b==c&&b0?(j=Math.ceil(e/2/p)*p-p,m=Number((e%p).toPrecision(14)),0!=m&&m!=p&&(j+=m)):(j=2*e,m=Number((-e%p).toPrecision(14)),0!=m&&m!=p&&(j=j+m-p)),S.min=j,Z.value=j,k=j+Math.round((o-j)/p)*p,S.max=k,ja.value=k):e>o&&(k=n+2*Math.ceil(((e-n)/p).toPrecision(16))*p,S.max=k,ja.value=k),S.value=e,ga.value=e}},A.append(T)}else if("boolean"==q){var na=$(''),oa=na[0],pa=$('');na.on("change",function(a){var b=oa.checked;o.assign(b,o.hciAgent,!0)}),m=function(a,e){e!==!0&&e!==!1||void 0!==a.eden_definition?f(b,c,d,g,h,i):(oa.checked=e,k(e))},k(p);var qa=$('');qa.append(na),qa.append(pa),A.append(qa)}else if("string"==q){var ra=$('"),sa=ra[0];ra.on("input",function(a){var b=sa.value;o.assign(b,Symbol.hciAgent,!0),sa.style.height="",sa.style.height=String(sa.scrollHeight+4)+"px"}),m=function(a,e){"string"!=typeof e||void 0!==a.eden_definition?f(b,c,d,g,h,i):(sa.value=e,sa.rows=e.split("\n").length,y.html(Eden.prettyPrintValue("",e,l,!1,!1)))},A.append($('
      ')),A.append(ra),A.append($('
      '))}else if("undefined"==q){if(A.append($('

      '+c+" is currently undefined.

      ")),!i){var ta=z.clone();ta[0].value="undefined",ta.on("change",j);var ua=$("");ua.append(ta);var va=$("
      ");va.append(ua),A.append(va)}m=function(a,e){void 0===e&&void 0===a.eden_definition||f(b,c,d,g,h,i)}}else m=function(a,e){void 0===e&&void 0===a.eden_definition||f(b,c,d,g,h,i)};return o.addJSObserver(b+"/"+c+"/"+d,m),s?(i&&A.find("input, textarea").attr("readonly","readonly"),g.append(A),g.accordion({active:"undefined"!=q&&void 0,collapsible:!0,heightStyle:"content"})):v.addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all observable-palette-static-header"),g.removeFromDialog=function(){h.remove(c,g,d)},g}function g(a,b){a.target.style.minWidth=b.size.width+"px"}var h=0,i={};root.addGlobal(function(a,b,d){if(d&&c(b)){var e=b.name.slice(1);for(var f in i)new RegExp("^"+f).test(e)&&i[f].push(e)}}),this.createDialog=function(b,c){function h(a,b){for(var c=b.data("observable"),d=b[0],e=p[c],f=0;f'),p={},q=$(''),r=q[0];q.on("keyup",function(a){13==a.which&&(j(r.value,0,!1),r.value="")}),q.autocomplete({minLength:2,source:d});var s=$('');s.click(function(){j(r.value,0,!1),r.value=""});var t=$('');t.on("click",function(a){l(r.value),r.value=""});var u=$(""),v=$(''),w=v[0];u.append(v),u.append(" Advanced");var x=root.lookup("_view_"+m+"_advanced"),y=x.value();void 0===y?(x.assign(!1,n),o.addClass("observable-palette-no-advanced")):y||o.addClass("observable-palette-no-advanced"),x.addJSObserver("repaintView",function(a,b){o.toggleClass("observable-palette-no-advanced",!b),w.checked=b}),v.on("change",function(a){x.assign(a.target.checked,n)});var z=$('
      ');z.append(q),z.append(s),z.append(t),z.append(u);var A=[],B=7,C=root.lookup("_view_"+m+"_observables"),D=C.value();Array.isArray(D)&&(D.length>0&&!Array.isArray(D[0])&&(D=[D]),D.length>B&&(B=D.length));for(var E=0;E');F.sortable({connectWith:".observable-palette-column, .observable-palette-dependencies",forcePlaceholderSize:!0,handle:"h3",items:">.observable-palette-obs-box",placeholder:"observable-palette-drag-placeholder",scroll:!1,tolerance:"pointer",receive:function(a,b){var c=a.target,d=b.item;h(c,d)}}),E')),e=($("
      "),$('
      '),$('
      '),$('
      '));d.append(e);var f=$('');d.append(f);var g={};e.on("click",".scriptgen-importex",function(a){var b=a.currentTarget.getAttribute("data-agent");g[b]?g[b]=!1:g[b]=!0,h()});var h=function(){e.html("");for(var a=c.generateScriptLines(g),b=0;b '+f[1]+"";if(f.length>2)for(var i=2;i'+(g[d]?"":"")+""+(g[d]?'## '+a.imports[b]+"":h)+"");e.append(j)}e.append($('
      '));var k=$("
      ");e.append(k);var l=a.definitions.join("\n")+"\n## When agents\n\n"+a.agents,m=new Eden.AST(l,(void 0),{name:"*JavaScript"}),n=new EdenUI.Highlight(k.get(0));n.highlight(m,-1,-1)};f.click(function(){h()}),h(),$('
      ').html(d).dialog({appendTo:"#jseden-views",title:b,width:790,height:700,minHeight:120,minWidth:230,dialogClass:"scriptgen-dialog"})};this.generateScriptLines=function(a){var b={},c=Eden.Generator.importsScript().split("\n");b.imports=c;var d=Eden.Generator.symbolScript(a).split("\n");b.definitions=d;var e=Eden.Agent.getActiveAgents(a,!1);return b.agents=e,b},this.baseConstrualSymbols={},this.changeListener=function(a,b){var d=a.last_modified_by;if(!b&&"include"!=d){var e=a.name.slice(1);void 0!==a.eden_definition&&void 0!==a.definition?c.baseConstrualSymbols[e]={eden_definition:a.eden_definition,last_modified_by:d}:c.baseConstrualSymbols[e]={cached_value:a.cached_value,last_modified_by:d}}},a.eden.listenTo("executeError",EdenUI.plugins.ScriptGenerator,function(a,b){root.removeGlobal(c.changeListener)}),this.baseConstrualURL="",a.views.ScriptGenerator={dialog:this.createDialog,title:"Script Generator",category:a.viewCategories.history},b()},EdenUI.plugins.ScriptGenerator.title="Script Generator",EdenUI.plugins.ScriptGenerator.description="Generates a definitional script that can be used to recreate the current state of the environment at a later time.",EdenUI.plugins.ScriptGenerator.originalAuthor="Joe Butler",EdenUI.plugins.ScriptGenerator.loadBaseConstrual=function(a){"ScriptGenerator"in edenUI.plugins&&root.addGlobal(edenUI.plugins.ScriptGenerator.changeListener),eden.include(a,"",{name:Symbol.getInputAgentName()},function(){"ScriptGenerator"in edenUI.plugins&&(root.removeGlobal(edenUI.plugins.ScriptGenerator.changeListener),edenUI.plugins.ScriptGenerator.baseConstrualURL=a)})},function(){"use strict";var a,b=this;a="undefined"!=typeof exports?exports:b.Springy={};var c=a.Graph=function(){this.nodeSet={},this.nodes=[],this.edges=[],this.adjacency={},this.nextNodeId=0,this.nextEdgeId=0,this.eventListeners=[]},d=a.Node=function(a,b){this.id=a,this.data=void 0!==b?b:{}},e=a.Edge=function(a,b,c,d){this.id=a,this.source=b,this.target=c,this.data=void 0!==d?d:{}};c.prototype.addNode=function(a){return a.id in this.nodeSet||this.nodes.push(a),this.nodeSet[a.id]=a,this.notify(),a},c.prototype.addNodes=function(){for(var a=0;a=0;b--)this.nodes[b].id===a.id&&this.nodes.splice(b,1);this.detachNode(a)},c.prototype.detachNode=function(a){var b=this.edges.slice();b.forEach(function(b){try{b.source.id!==a.id&&b.target.id!==a.id||this.removeEdge(b)}catch(c){}},this),this.notify()},c.prototype.removeEdge=function(a){for(var b=this.edges.length-1;b>=0;b--)this.edges[b].id===a.id&&this.edges.splice(b,1);for(var c in this.adjacency){for(var d in this.adjacency[c]){for(var e=this.adjacency[c][d],f=e.length-1;f>=0;f--)this.adjacency[c][d][f].id===a.id&&this.adjacency[c][d].splice(f,1);0==this.adjacency[c][d].length&&delete this.adjacency[c][d]}j(this.adjacency[c])&&delete this.adjacency[c]}this.notify()},c.prototype.merge=function(a){var b=[];a.nodes.forEach(function(a){b.push(this.addNode(new d(a.id,a.data)))},this),a.edges.forEach(function(a){var c=b[a.from],d=b[a.to],f=a.directed?f=a.type+"-"+c.id+"-"+d.id:c.idb.x&&(b.x=d.p.x),d.p.y>b.y&&(b.y=d.p.y)});var c=b.subtract(a).multiply(.07);return{bottomleft:a.subtract(c),topright:b.add(c)}};var h=a.Vector=function(a,b){this.x=a,this.y=b};h.random=function(){return new h(10*(Math.random()-.5),10*(Math.random()-.5))},h.prototype.add=function(a){return new h(this.x+a.x,this.y+a.y)},h.prototype.subtract=function(a){return new h(this.x-a.x,this.y-a.y)},h.prototype.multiply=function(a){return new h(this.x*a,this.y*a)},h.prototype.divide=function(a){return new h(this.x/a||0,this.y/a||0)},h.prototype.magnitude=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},h.prototype.normal=function(){return new h((-this.y),this.x)},h.prototype.normalise=function(){return this.divide(this.magnitude())},f.ForceDirected.Point=function(a,b){this.p=a,this.m=b,this.v=new h(0,0),this.a=new h(0,0)},f.ForceDirected.Point.prototype.applyForce=function(a){this.a=this.a.add(a.divide(this.m))},f.ForceDirected.Spring=function(a,b,c,d){this.point1=a,this.point2=b,this.length=c,this.k=d};var i=a.Renderer=function(a,b,c,d){this.layout=a,this.clear=b,this.drawEdge=c,this.drawNode=d,this.layout.graph.addGraphListener(this)};i.prototype.graphChanged=function(a){this.start()},i.prototype.start=function(){var a=this;this.layout.start(function(){a.clear(),a.layout.eachEdge(function(b,c){a.drawEdge(b,c.point1.p,c.point2.p)}),a.layout.eachNode(function(b,c){a.drawNode(b,c.p)})})},i.prototype.stop=function(){this.layout.stop()},Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("[object Function]"!={}.toString.call(a))throw new TypeError(a+" is not a function");for(b&&(c=b),d=0;d1||g<0||g>1)&&new Springy.Vector(a.x+f*(b.x-a.x),a.y+f*(b.y-a.y))}function c(a,c,d,e,f){var g,h={x:d.x,y:d.y},i={x:d.x+e,y:d.y},j={x:d.x,y:d.y+f},k={x:d.x+e,y:d.y+f};return(g=b(a,c,h,i))?g:(g=b(a,c,i,k))?g:(g=b(a,c,k,j))?g:!!(g=b(a,c,j,h))&&g}var d=this.graph=a.graph||new Springy.Graph,e=a.stiffness||100,f=a.repulsion||5e3,g=a.damping||.5,h=a.nodeSelected||null,i=this[0],j=i.getContext("2d"),k=this.layout=new Springy.Layout.ForceDirected(d,e,f,g),l=k.getBoundingBox(),m={bottomleft:new Springy.Vector((-2),(-2)),topright:new Springy.Vector(2,2)};Springy.requestAnimationFrame(function a(){m=k.getBoundingBox(),l={bottomleft:l.bottomleft.add(m.bottomleft.subtract(l.bottomleft).divide(10)),topright:l.topright.add(m.topright.subtract(l.topright).divide(10))},Springy.requestAnimationFrame(a)});var n=function(a){var b=l.topright.subtract(l.bottomleft),c=a.subtract(l.bottomleft).divide(b.x).x*i.width,d=a.subtract(l.bottomleft).divide(b.y).y*i.height;return new Springy.Vector(c,d)},o=function(a){var b=l.topright.subtract(l.bottomleft),c=a.x/i.width*b.x+l.bottomleft.x,d=a.y/i.height*b.y+l.bottomleft.y;return new Springy.Vector(c,d)},p=null,q=null,r=null;jQuery(i).mousedown(function(a){var b=jQuery(this).offset(),c=o({x:a.pageX-b.left,y:a.pageY-b.top});p=q=r=k.nearest(c),null!==p.node&&(r.point.m=1e4,h&&h(p.node)),s.start()}),jQuery(i).dblclick(function(a){var b=jQuery(this).offset(),c=o({x:a.pageX-b.left,y:a.pageY-b.top});p=k.nearest(c),node=p.node,node&&node.data&&node.data.ondoubleclick&&node.data.ondoubleclick()}),jQuery(i).mousemove(function(a){var b=jQuery(this).offset(),c=o({x:a.pageX-b.left,y:a.pageY-b.top});q=k.nearest(c),null!==r&&null!==r.node&&(r.point.p.x=c.x,r.point.p.y=c.y),s.start()}),jQuery(window).bind("mouseup",function(a){r=null}),Springy.Node.prototype.getWidth=function(){var a=void 0!==this.data.label?this.data.label:this.id;if(this._width&&this._width[a])return this._width[a];j.save(),j.font="16px Verdana, sans-serif";var b=j.measureText(a).width+10;return j.restore(),this._width||(this._width={}),this._width[a]=b,b},Springy.Node.prototype.getHeight=function(){return 20};var s=this.renderer=new Springy.Renderer(k,function(){var a=i.parentNode;null!==a&&(i.height=a.clientHeight,i.width=a.clientWidth),j.clearRect(0,0,i.width,i.height)},function(a,b,e){for(var f=n(b).x,g=n(b).y,h=n(e).x,i=n(e).y,k=new Springy.Vector(h-f,i-g),l=k.normal().normalise(),m=d.getEdges(a.source,a.target),o=d.getEdges(a.target,a.source),p=m.length+o.length,q=0,r=0;r'),h=$("").springy({graph:f,nodeSelected:function(a){}});g.append(h);var i=$('
      ');g.append(i);var j=$(''),k=j.get(0),l=$(''),m=l.get(0);i.append(j),i.append($("").append(l)),j.on("input",e),l.on("change",e),g.on("mouseenter",e),g.dialog({appendTo:"#jseden-views",title:d,width:600,height:450,minHeight:120,minWidth:230,dialogClass:"dependency-map-dialog"})},this.updateGraph=function(a,b){a.re=b,a.newNodes=[],a.newEdges=[];for(var c in root.symbols){var d=root.symbols[c],e=d.name;if(b.test(e)){a.newNodes.indexOf(e)==-1&&a.newNodes.push(e);var f=d.dependencies;for(var g in f){var h=f[g].name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h),a.newEdges.push([h,e,!1])}f=d.dynamicDependencies;for(var g in f){var h=f[g].name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h),a.newEdges.push([h,e,!0])}f=d.observees;for(var g in f){var h=f[g].name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h),a.newEdges.push([h,e,!1])}var i=d.subscribers;for(var g in i){var j=i[g],h=j.name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h);var k=d.name in j.dynamicDependencies;a.newEdges.push([e,h,k])}i=d.observers;for(var g in i){var h=i[g].name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h),a.newEdges.push([e,h,!1])}}}if(!arrayCompare(a.previousNodes,a.newNodes)||!arrayCompare(a.previousEdges,a.newEdges)){a.previousNodes=a.newNodes,a.previousEdges=a.newEdges,a.filterEdges(function(a){return!1}),a.filterNodes(function(a){return!1}),a.nodeObjectsStore={};for(var c in a.previousNodes){var l=a.previousNodes[c];a.nodeObjectsStore[l]=a.newNode({label:l},{color:"#6A4A3C"})}for(var g in a.previousEdges){var m=a.previousEdges[g][0],n=a.previousEdges[g][1],o={};a.previousEdges[g][2]&&(o.dashes=[10,10]),a.newEdge(a.nodeObjectsStore[m],a.nodeObjectsStore[n],o)}}},a.views.DependencyMap={dialog:this.createDialog,title:"Dependency Map",category:a.viewCategories.comprehension,menuPriority:2},b()},EdenUI.plugins.DependencyMap.title="Dependency Map",EdenUI.plugins.DependencyMap.description="Displays a diagram showing the relationships between observables.",EdenUI.plugins.DependencyMap.author="Joe Butler",EdenUI.plugins.StateTimeLine=function(a,b){var c=this;this.createDialog=function(b,e){c.ignoreRE=new RegExp("((_view.*)|(_View.*)|(_status)|(mouse.*)|(picture))"),code_entry=$('
      ').append($('')).append($('').click(function(){c.ST.states.push(d("partial"));var e=document.getElementById(b+"-regex").value;""==e&&(e="State "+c.ST.nextBlankState),$("#"+b+"-content-states").append("
      "+e+": Restore "+(new Date).toLocaleTimeString()+" Delete
      "),document.getElementById(b+"-regex").value="",a.plugins.StateTimeLine.ST.nextBlankState++})).append($('
      ')),$dialog=$('
      ').html(code_entry).dialog({title:e,width:300,height:450,minHeight:120,minWidth:230})},c.ST={},c.ST.states=[],c.ST.nextBlankState=0,this.deleteState=function(a){$(document.getElementById("stdiv"+a)).remove()},this.changeState=function(b){for(var c in root.symbols)Eden.isitSystemSymbol(root.symbols[c].name.substring(1,root.symbols[c].name.length))||a.plugins.StateTimeLine.ignoreRE.test(root.symbols[c].name.substring(1,root.symbols[c].name.length))||delete root.symbols[c];a.plugins.ScriptInput.submitEdenCode(a.plugins.StateTimeLine.ST.states[b])};var d=function(b){var c=[],d=[],e=[],f=[],g="autocalc = 1;",h="autocalc = 0;",i=root.lookup("picture").eden_definition;void 0==i?i="picture is [];":i+=";";for(var j in root.symbols){var k="@",l="",m=5,n=root.symbols[j],o=n.eden_definition;if(void 0==o&&(o=k),0==o.indexOf("proc")){if(l="(Action)",m=2,"partial"==b&&Eden.isitSystemAgent(j))continue}else if(0==o.indexOf("func")){if(l="(Function)",m=1,"partial"==b&&Eden.isitSystemFunction(j))continue}else if(l="(Observable)",m=0,"partial"==b&&Eden.isitSystemObservable(j))continue;var p=Eden.edenCodeForValue(n.cached_value);if(!a.plugins.StateTimeLine.ignoreRE.test(j))if(1==m)f.push(o);else if(0==m){if(p==k&&o==k)continue;o==k?d.push(j+" = "+p+";"):c.push(o+";")}else 2==m?e.push(o):console.log("oh dear error")}var q=[];q.push(h);for(var r=0;r

      ';return $dialog=$('
      ').html(e).dialog({title:c,width:300,height:450,minHeight:120,minWidth:230}),$("#connectBtn").click(function(){function b(b){var c=a.eden.root,d=c.lookup("definitionOf").definition(c)(b);e.send(d)}if(window.WebSocket=window.WebSocket||window.MozWebSocket,!window.WebSocket)return void console.log("WebSockets not supported");var c="ws://"+$("#sl-ipaddr").val()+":"+$("#sl-port").val()+"/",e=new WebSocket(c);eden.listenTo("executeBegin",this,function(a,b){"net"!=a&&e.send(b)}),eden.listenTo("beforeAssign",this,function(a,b,c){"net"!=c&&e.send(a.name.slice(1)+"="+Eden.edenCodeForValue(b)+";")}),$("#sl-status").html("

      Connected to: "+c+"

      "), +var c=this.ast.getStatementByLine(this.curline);if(c){var d=c.getRange(),e=Math.floor((d[1]-d[0])/2)+d[0];b||(changeClass(this.gutter.childNodes[e],"play",!1),changeClass(this.gutter.childNodes[e],"current",!1))}}this.curline=a-1;var c=this.ast.getStatementByLine(a-1);if(c){c.getRange||console.error("NO GETRANGE",c);var d=c.getRange();if(d[0]0?(j.errors[0].line==a+1?(c+=" error",e="",i=j.errors[0].messageText(),h=a):"runtime"==j.errors[0].type&&(c+=" error",e="",i=j.errors[0].messageText()),this.lines[a].errored=!0,g=!0):(d.errors.length>0&&d.errors[0].line==a+1&&(this.lines[a].errored=!0,c+=" error",e="",i=d.errors[0].messageText()),this.lines[a].errored&&(g=!0,this.lines[a].errored=!1),j.warning&&(c+=" warning",e="",g=!0,j.warning&&(i=j.warning.messageText())),1==j.executed?(c+=" executed",g=!0,this.lines[a].executed=!0):2==j.executed?(c+=" guarded",g=!0,this.lines[a].executed=!0):3==j.executed&&(c+=" errorblock",g=!0)),this.lines&&this.lines[a]&&(this.lines[a].executed&&j.executed<=0&&(g=!0,this.lines[a].executed=!1),this.lines[a].selected&&(c+=" select"),this.lines[a].live&&(c+=" live"))):(this.errors&&this.errors.length>0&&this.errors[0].line==a+1?this.lines[a].errored||(c+=" error",e="",i=this.errors[0].messageText(),h=a,this.lines[a].errored=!0,g=!0):this.lines[a].errored&&(g=!0,this.lines[a].errored=!1,i=""),this.lines[a].executed&&(g=!0,this.lines[a].executed=!0)),f)if(""==e){var k=document.createElement("div");k.className=c,k.innerHTML="",k.setAttribute("data-line",""+a),this.gutter.replaceChild(k,this.gutter.childNodes[a])}else this.gutter.childNodes[a].className=c,this.gutter.childNodes[a].innerHTML=e;else g&&(this.gutter.childNodes[a].className.indexOf("hover")>=0&&(c+=" hover"),this.gutter.childNodes[a].className.indexOf("play")>=0&&(c+=" play"),this.gutter.childNodes[a].className.indexOf("current")>=0&&(c+=" current"),this.gutter.childNodes[a].innerHTML=e,this.gutter.childNodes[a].className=c,i&&(this.gutter.childNodes[a].title=i))},EdenScriptGutter.prototype.generate=function(a,b){if(this.ast=a,!this.edits){var c=!1,d=a.getNumberOfLines()+1;if(d>this.lineelements.childNodes.length&&(d=this.lineelements.childNodes.length),d!=this.gutter.childNodes.length){for(this.hideBrace();this.gutter.firstChild;)this.gutter.removeChild(this.gutter.firstChild);for(var e=0;e0?this.hideBrace():this.hovering||this.selectLine(b)}},EdenUI.ScriptArea=function(){this.contents=document.createElement("div"),this.intextarea=document.createElement("textarea"),this.intextarea.autofocus=!0,this.intextarea.tabIndex=1,this.intextarea.className="hidden-textarea2",this.contents.appendChild(this.intextarea),this.codearea=document.createElement("div"),this.codearea.className="inputCodeArea",this.contents.appendChild(this.codearea),this.outdiv=document.createElement("div"),this.outdiv.contenteditable=!0,this.outdiv.className="outputcontent",this.outdiv.spellcheck=!1,this.outdiv.tabIndex=2,this.codearea.appendChild(this.outdiv),this.fragment=void 0,this.readonly=!1,this.alwaysreadonly=!1,this.currentlineno=-1,this.currentcharno=-1,this.gotomode=!1,this.highlighter=new EdenUI.Highlight(this.outdiv),this.gutter=new EdenScriptGutter(this.codearea,this.infobox,this.outdiv),this.details=new EdenUI.ScriptArea.Details(this),this.cachedhlopt=void 0,this.disablehl=!1,this.highlighter.setScrollTop(0);var a=this;this.gutterinterval=setInterval(function(){if(void 0!==a.fragment&&void 0!==a.fragment.ast){a.gutter.generate(a.fragment.ast.script,a.currentlineno);for(var b in a.highlighter.metrics)if(a.currentlineno!=b){var c=a.highlighter.metrics[b];if(c.query)for(var d=0;d0?f:"value");g=1==g.length?g[0]:g.length>1?g.join(", "):"",c.qelements[d].setAttribute("data-result",g)}c.squery&&a.highlightContent(b,a.intextarea.selectionEnd)}}},300);new EdenUI.ScriptArea.Keyboard(this),new EdenUI.ScriptArea.Mouse(this);this.rebuildinterval=400},EdenUI.ScriptArea.prototype.setReadonly=function(a){this.alwaysreadonly=a,a===!0?(this.readonly=!0,this.outdiv.contentEditable=!1):(this.readonly=!!this.fragment&&this.fragment.locked,this.outdiv.contentEditable=!this.readonly,"comment"==a&&this.updateEntireHighlight())},EdenUI.ScriptArea.prototype.setFragment=function(a){if(this.fragment&&this.fragment!==a&&(this.fragment.unlock(),this.currentlineno=-1),this.details.hide(),this.fragment=a,void 0===a)return this.gutter.clear(),changeClass(this.outdiv,"browser",!0),this.outdiv.contentEditable=!1,void(this.readonly=!0);var b=this;a.reset(function(){changeClass(b.outdiv,"browser",!1),b.intextarea.value=a.getSource(),a.ast&&(b.highlightContent(-1,0),b.intextarea.focus(),b.checkScroll(),b.gutter.setBaseAST(a.ast.script)),a.locked?(b.readonly=!0,b.outdiv.contentEditable=!1):(b.readonly=b.alwaysreadonly===!0,b.outdiv.contentEditable=!b.readonly)})},EdenUI.ScriptArea.prototype.refresh=function(){this.intextarea.value=this.fragment.getSource(),this.fragment.ast&&this.highlightContent(-1,0)},EdenUI.ScriptArea.prototype.updateSource=function(a,b){this.fragment.setSource(a),this.gutter.errors=this.fragment.ast.errors,this.highlighter.ast=this.fragment.ast},EdenUI.ScriptArea.prototype.updateLineHighlight=function(){var a=-1,b=-1;document.activeElement===this.intextarea&&(b=this.intextarea.selectionEnd,a=this.getLineNumber(this.intextarea)),this.updateSource(this.intextarea.value,a),this.runScript(a),this.highlightContent(a,b)},EdenUI.ScriptArea.prototype.runScript=function(a){if(this.gutter.lines[a-1]&&this.gutter.lines[a-1].live&&!this.fragment.ast.hasErrors()){var b=this.fragment.ast.script.getStatementByLine(a-1);this.fragment.ast.executeStatement(b,a,this.fragment)}},EdenUI.ScriptArea.prototype.hideInfoBox=function(){},EdenUI.ScriptArea.prototype.updateLineCachedHighlight=function(){if(this.fragment){var a=-1,b=-1;document.activeElement===this.intextarea&&(b=this.intextarea.selectionEnd,a=this.getLineNumber(this.intextarea)),this.highlightContent(a,b)}},EdenUI.ScriptArea.prototype.updateEntireHighlight=function(a,b){if(void 0!==this.fragment){this.cachedhlopt=b,this.updateSource(this.intextarea.value,-1);var c=-1;document.activeElement===this.intextarea&&(c=this.intextarea.selectionEnd),a&&runScript(0),this.highlightContent(-1,c,b)}},EdenUI.ScriptArea.prototype.updateCachedHighlight=function(a){var b=-1;document.activeElement===this.intextarea&&(b=this.intextarea.selectionEnd),this.highlightContent(-1,b,a?a:this.cachedhlopt)},EdenUI.ScriptArea.prototype.findElementLineNumber=function(a){for(var b=a;b.parentNode!==this.outdiv;)b=b.parentNode;var c=parseInt(b.getAttribute("data-line"));return c},EdenUI.ScriptArea.prototype.replaceLine=function(a,b){var c=this.intextarea.value.split("\n");c[a]=b,this.intextarea.value=c.join("\n")},EdenUI.ScriptArea.prototype.focusOutput=function(){this.setCaretToFakeCaret(),this.outdiv.focus()},EdenUI.ScriptArea.prototype.focusText=function(){if(!this.readonly){var a=getCaretCharacterOffsetWithin(this.outdiv),b=getStartCaretCharacterOffsetWithin(this.outdiv);this.intextarea.focus(),this.intextarea.selectionEnd=a,this.intextarea.selectionStart=b,b!=a&&(this.refreshentire=!0)}},EdenUI.ScriptArea.prototype.toggleHighlighting=function(){this.disablehl=!this.disablehl,this.updateEntireHighlight(),this.gutter.clear()},EdenUI.ScriptArea.prototype.highlightContent=function(a,b,c){if(this.fragment){var d=this.fragment.ast;if(d){if(void 0===c&&this.disablehl&&(c={}),this.disablehl&&(c.disabled=!0),this.highlighter.highlight(d,a,b,c),document.activeElement!==this.intextarea&&$(this.outdiv).find(".fake-caret").addClass("fake-blur-caret"),"comment"==this.alwaysreadonly)for(var e=$(this.outdiv).find(".eden-comment-line"),f=0;f")},axis:"x",distance:5,drag:function(b,c){if(!a.readonly){var d;if(a.dragint?d=Math.round(a.dragvalue+(c.position.left-a.dragstart)/2):(d=a.dragvalue+.005*(c.position.left-a.dragstart),d=d.toFixed(4)),d!=a.draglast){a.draglast=d,b.target.innerHTML=""+d;var e=b.target.parentNode.textContent;"\n"==e.charAt(e.length-1)&&(e=e.slice(0,-1)),a.replaceLine(a.dragline,e),a.updateSource(a.intextarea.value,a.dragline),a.runScript(a.dragline+1),a.highlightContent(a.dragline,-1)}}},start:function(b,c){if(!a.readonly){a.edited=!0,a.dragline=a.findElementLineNumber(b.target),a.dragstart=c.position.left;var d=b.target.textContent;d.indexOf(".")==-1?(a.dragvalue=parseInt(d),a.dragint=!0):(a.dragvalue=parseFloat(d),a.dragint=!1),a.draglast=a.dragvalue,$(b.target).addClass("eden-select"),$(a.outdiv).css("cursor","ew-resize")}},stop:function(b,c){a.readonly||($(b.target).removeClass("eden-select"),$(a.outdiv).css("cursor","text"),a.dragline=-1)},cursor:"move",cursorAt:{top:-5,left:-5}}).click(function(){$(this).draggable({disabled:!0})}).blur(function(){$(this).draggable({disabled:!1})}))},EdenUI.ScriptArea.prototype.getLineNumber=function(){var a=this.intextarea.value.substr(0,this.intextarea.selectionStart).split("\n");return this.currentlineno=a.length,this.currentcharno=a[a.length-1].length,this.currentlineno},EdenUI.ScriptArea.prototype.gotoLine=function(a){var b=this.intextarea.value.split("\n");b.length=a+1;var c=b.join("\n").length;this.intextarea.focus(),this.intextarea.selectionEnd=c,this.intextarea.selectionStart=c,this.updateLineCachedHighlight()},EdenUI.ScriptArea.prototype.checkScroll=function(){return},EdenUI.ScriptArea.prototype.setCaretToFakeCaret=function(){var a=$(this.outdiv).find(".fake-caret").get(0);if(a){var b=document.createRange(),c=window.getSelection();a.nextSibling&&(a=a.nextSibling),b.setStart(a,0),b.collapse(!0),c.removeAllRanges(),c.addRange(b),$(this.outdiv).remove(".fake-caret")}},EdenUI.ScriptArea.prototype.makeDiff=function(){var a={},b=this.fragment.diff(),c=0;for(var d in b.remove)if(!b.remove[d].consecutive){var e=parseInt(d),f=0,g=20;do g+=20,f++;while(b.remove[e+f]&&b.remove[e+f].consecutive);a[b.remove[d].nline+c]=g}this.gutter.setDiffs(b),this.cachedhlopt={spacing:a},this.updateCachedHighlight()},EdenUI.ScriptArea.prototype.doRebuild=function(){this.makeNumbersDrag()},EdenUI.ScriptArea.prototype.delayRebuild=function(){var a=this;clearTimeout(this.rebuildtimer),this.rebuildtimer=setTimeout(function(){a.doRebuild()},this.rebuildinterval)},EdenUI.ScriptArea.prototype.rebuild=function(){this.gutter.edits?(this.updateSource(this.intextarea.value,-1),this.gutter.ast=this.fragment.ast,this.makeDiff()):(this.edited=!0,this.refreshentire?(this.updateEntireHighlight(),this.refreshentire=!1):this.updateLineHighlight(),this.checkScroll(),this.dirty=!1)},EdenUI.ScriptArea.prototype.enableGotoMode=function(){this.gotomode||(this.outdiv.contentEditable=!1,changeClass(this.outdiv,"goto",!0),this.gotomode=!0)},EdenUI.ScriptArea.prototype.disableGotoMode=function(){this.gotomode&&(this.outdiv.contentEditable=!0,changeClass(this.outdiv,"goto",!1),this.gotomode=!1)},EdenUI.ScriptArea.prototype.insertTab=function(){var a=this.intextarea.selectionStart,b=this.intextarea.selectionEnd;this.intextarea.value=this.intextarea.value.substring(0,a)+"\t"+this.intextarea.value.substring(b),this.intextarea.selectionStart=this.intextarea.selectionEnd=a+1,this.rebuild()},EdenUI.ScriptArea.Details=function(a){this.scriptarea=a,this.contents=document.createElement("div"),this.contents.className="script-details",this.contents.addEventListener("keyup",function(a){var b=a.target.parentNode.getAttribute("data-name"),c=a.target.value;console.log("CHANGE PROP",b,c)}),this.visible=!1},EdenUI.ScriptArea.Details.prototype.addProperty=function(a,b,c,d){var e=document.createElement("div");e.className="script-details-prop",e.setAttribute("data-name",a);var f=document.createElement("div");f.className="script-details-label",f.textContent=b,e.appendChild(f);var g=document.createElement("input");g.className="script-details-value",g.value=c?c:"",g.setAttribute("type","text"),d&&d.readonly&&(g.className+=" script-details-readonly",g.setAttribute("readonly","true")),e.appendChild(g);var h=document.createElement("div");return h.className="script-details-status",d&&d.readonly?h.innerHTML="":h.innerHTML="",e.appendChild(h),this.contents.appendChild(e),e},EdenUI.ScriptArea.Details.prototype.clear=function(){for(;this.contents.lastChild;)this.contents.removeChild(this.contents.lastChild)},EdenUI.ScriptArea.Details.prototype.addButtons=function(){var a=document.createElement("div");a.className="script-details-buttons";var b=document.createElement("button");b.className="script-button",b.innerHTML='Close',a.appendChild(b),this.contents.appendChild(a)},EdenUI.ScriptArea.Details.prototype.show=function(){this.clear(),this.addProperty("name","Name",this.scriptarea.fragment.name),this.addProperty("selector","Path",this.scriptarea.fragment.selector,{readonly:!0}),this.scriptarea.fragment.originast&&this.addProperty("id","Full Name",Eden.Selectors.getID(this.scriptarea.fragment.originast),{readonly:!0});var a=this.scriptarea.fragment.doxy;if(a){this.addProperty("desc","Description",a.stripped()),this.addProperty("tags","Tags",a.getHashTags().join(" "));var b=a.getControls();for(var c in b)this.addProperty(c,c.substring(1),b[c])}this.addButtons(),this.scriptarea.codearea.appendChild(this.contents),changeClass(this.scriptarea.outdiv,"blur",!0),this.visible=!0},EdenUI.ScriptArea.Details.prototype.hide=function(){this.visible&&(this.scriptarea.codearea.removeChild(this.contents),this.visible=!1,changeClass(this.scriptarea.outdiv,"blur",!1))},EdenUI.ScriptArea.Details.prototype.toggle=function(){this.visible?this.hide():this.show()},EdenUI.ScriptArea.Keyboard=function(a){function b(a){var b=a.key;return a.shiftKey&&(b="Shift-"+b),a.altKey&&(b="Alt-"+b),(a.ctrlKey||a.metaKey)&&(b="Ctrl-"+b),b}function c(c){var d=b(c);switch(d){case"Tab":c.preventDefault(),a.insertTab();break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Home":case"End":a.moveCaret();break;case"Ctrl-a":a.selectAll(),c.preventDefault();break;case"Ctrl-h":a.toggleHighlighting(),c.preventDefault();break;case"Ctrl-Shift-ArrowLeft":case"Ctrl-Shift-ArrowRight":case"Ctrl-Shift-ArrowUp":case"Ctrl-Shift-ArrowDown":case"Ctrl-Shift-Home":case"Ctrl-Shift-End":case"Shift-ArrowLeft":case"Shift-ArrowRight":case"Shift-ArrowUp":case"Shift-ArrowDown":case"Shift-Home":case"Shift-End":a.focusOutput();break;case"Backspace":a.refreshentire=10==a.intextarea.value.charCodeAt(a.intextarea.selectionStart-1);break;case"Enter":a.refreshentire=!0;break;case"Ctrl-Control":a.enableGotoMode()}}function d(b){a.refreshentire=!0}function e(c){var d=b(c);switch(c.ctrlKey||a.disableGotoMode(),d){case"Ctrl-Control":a.disableGotoMode();break;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":case"Home":case"End":a.updateLineCachedHighlight(),a.gutter&&a.gutter.selectLine(a.currentlineno),a.checkScroll()}}function f(b){"INPUT"!=b.target.nodeName&&"textarea"!=b.target.nodeName&&(!b.shiftKey||37!=b.keyCode&&38!=b.keyCode&&39!=b.keyCode&&40!=b.keyCode&&35!=b.keyCode&&36!=b.keyCode)&&"Control"!=b.key&&"Shift"!=b.key&&"c"!=b.key&&a.focusText()}function g(b){a.intextarea.focus(),setTimeout(function(){a.updateEntireHighlight()},0)}function h(b){"INPUT"!=b.target.nodeName&&"textarea"!=b.target.nodeName&&(17!=b.keyCode&&91!=b.keyCode&&92!=b.keyCode||a.disableGotoMode())}function i(b){$(a.outdiv).find(".fake-caret").remove()}function j(b){a.dirty=!0,a.rebuild()}function k(a){}a.intextarea.addEventListener("input",j),a.intextarea.addEventListener("keydown",c),a.intextarea.addEventListener("keyup",e),a.intextarea.addEventListener("paste",d),a.outdiv.addEventListener("keydown",f),a.outdiv.addEventListener("keyup",h),a.outdiv.addEventListener("paste",g),a.intextarea.addEventListener("blur",i),a.intextarea.addEventListener("focus",k)},EdenUI.ScriptArea.Mouse=function(a){function b(b){a.readonly}function c(b){if(console.log(b.target.nodeName),"INPUT"!=b.target.nodeName&&"textarea"!=b.target.nodeName&&(a.hideInfoBox(),!a.readonly&&0!=b.target.isContentEditable))if(a.gotomode){var c=b.target;if(""==c.className&&"SPAN"==c.parentNode.nodeName&&(c=c.parentNode),"eden-selector"==c.className||"eden-selector2"==c.className){a.disableGotoMode();var d=c.parentNode.textContent;console.log("PATH",d),Eden.Selectors.goto(d)}else if("eden-observable"==c.className){var e=c.getAttribute("data-observable");Eden.Selectors.goto(e+":active")}b.preventDefault()}else if(document.activeElement===a.outdiv){var f=getCaretCharacterOffsetWithin(a.outdiv),g=getStartCaretCharacterOffsetWithin(a.outdiv);if(g!=f)a.refreshentire=!0;else{a.intextarea.focus(),a.intextarea.selectionEnd=f,a.intextarea.selectionStart=f;a.currentlineno;a.updateLineCachedHighlight()}}}a.outdiv.addEventListener("mouseup",c),a.outdiv.addEventListener("mousedown",b)},EdenUI.plugins.PluginManager=function(a,b){this.createDialog=function(b,c){var d,e,f,g=$('
      '),h=function(b){return a.plugins[b]?"(loaded)":"(not loaded)"};pluginNames=Object.keys(EdenUI.plugins).sort(function(b,c){var d=a.plugins[b],e=a.plugins[c];return d&&!e?1:e&&!d?-1:b
      '+d.title+"
      ";void 0!==d.originalAuthor&&(k=k+""),void 0!==d.author&&(f=void 0===d.originalAuthor?"By ":"Built on by ",k=k+""),k=k+'",$(k).click(function(b){return function(){var c=$(this);a.loadPlugin(b,function(){a.plugins[b]&&(c.find(".pluginlist-loaded").html(h(b)),c.addClass("pluginmanager-loaded",100)),a.menu.updateViewsMenu()})}}(e)).appendTo(g)}var l=$('
      ');l.append(g),$dialog=$('
      ').html(l).dialog({title:c,width:310,height:400,minHeight:120,minWidth:230,dialogClass:"unpadded-dialog"})},a.views.PluginManager={dialog:this.createDialog,title:"Plug-in Manager",category:a.viewCategories.environment,name:"plugins"},b()},EdenUI.plugins.PluginManager.title="Plug-in Manager",EdenUI.plugins.PluginManager.description="Provides the ability to load plug-ins.",EdenUI.plugins.Canvas2D=function(a,b){var c=this;this.defaultFontSizePx=13.3,this.defaultLineHeight=1.75*this.defaultFontSizePx,this.defaultLineWidth=2;var d=600,e=500;canvases={},contents={};var f,g,h,i={},j=40,k=!1,l=!1;Object.defineProperty(this,"mouseIdleTimeout",{set:function(a){clearInterval(g),g=setInterval(function(){if(k)l=!1,k=!1;else if(!l){var a=root.lookup("mouseFollow").value();root.lookup("mouseVelocity").assign(new Point(0,0),root.scope,Symbol.hciAgent,a),l=!0,h=void 0}},a/2),f=a},get:function(){return f},enumerable:!0}),this.mouseVelocitySampleTime=100,this.mouseVelocityDampening=.3,this.mouseIdleTimeout=300;var m=function(a,b){var c;for(c in b)if("false"!=b[c][0].getAttribute("data-garbage"))for(var d=b[c],e=0;em?(e=j,d=i*(e/h),f=0,g=(k-d)/2):(d=k,e=j,f=0,g=0);var n=document.createElement("canvas");n.setAttribute("width","200"),n.setAttribute("height","112");var o=n.getContext("2d");o.drawImage(b,f,g,e,d);var p;try{p=n.toDataURL("image/png")}catch(q){}a&&a(p)},this.drawPicture=function(a){var b=canvases[a];if(void 0!==b&&!b.drawingQueued&&(b.drawingQueued=!0,!b.drawingInProgress)){var d=function(){b.drawingInProgress=!0,b.drawingQueued=!1;var e=i[a],f={},g="view_"+a+"_content",h=root.lookup(g),k=h.value(),l=b.getContext("2d"),n=contents[a],o=0;if(void 0!==n){var p=root.lookup("view_"+a+"_background_colour").value();void 0===p&&(p="white"),l.setTransform(1,0,0,1,0,0),c.setFillStyle(l,p),n.style.backgroundColor=p,l.fillRect(0,0,b.width,b.height);var q;for(q in e)e[q][0].setAttribute("data-garbage",!0);if(Array.isArray(k)){var r=root.lookup("view_"+a+"_scale").value();"number"!=typeof r&&(r=1);var s=root.lookup("view_"+a+"_zoom").value();"number"!=typeof s&&(s=1);var t,u,v=r*s;r<0?(l.scale(-v,v),v=-v,u=-r,t=!0):(1!=v&&l.scale(v,v),u=r,t=!1);var w=root.lookup("view_"+a+"_offset").value();if(w instanceof Point)if(t){var x=b.height/v-w.y;l.translate(w.x,-x),w=new Point(w.x,x)}else l.translate(w.x,w.y);else w=new Point(0,0);c.configureContextDefaults(l,u);for(var y=[k],z=[0],A=[],B="";y.length>0;){var C=y.pop(),D=z.pop();for(D>0&&C[D-1]instanceof EdenUI.plugins.Canvas2D.Transform&&(l.restore(),A.pop(),B=A.join(" "));D=d;i-=c){var j=(Math.round(i*b)-.5)/b;h.moveTo(j,e),h.lineTo(j,g),h.stroke()}for(var k=0==a.y?c:0;k<=g;k+=c){var l=(Math.round(k*b)-.5)/b;h.moveTo(d,l),h.lineTo(f,l),h.stroke()}for(var k=-c;k>=e;k-=c){var l=(Math.round(k*b)-.5)/b;h.moveTo(d,l),h.lineTo(f,l),h.stroke()}},this.configureContextDefaults=function(a,b){a.lineJoin="bevel",a.miterLimit=429496656,a.lineWidth=this.defaultLineWidth/b},this.configureContext=function(a,b,c,d){if("object"!=typeof d)return!0;if(d.visible===!1)return!1;if(Array.isArray(d.dashes)&&(a.setLineDash(d.dashes),"dashOffset"in d&&(a.lineDashOffset=d.dashOffset)),"cap"in d&&(a.lineCap=d.cap),"join"in d&&(a.lineJoin=d.join),"miterLimit"in d&&(a.miterLimit=d.miterLimit),"lineWidth"in d&&(a.lineWidth=d.lineWidth/b),"opacity"in d&&(a.globalAlpha=d.opacity),"object"==typeof d.shadow)if(a.shadowColor=d.shadow.colour,d.shadow.scale){var e=c*b;a.shadowBlur=d.shadow.blur*e,a.shadowOffsetX=d.shadow.xOffset*e,a.shadowOffsetY=d.shadow.yOffset*e}else a.shadowBlur=d.shadow.blur*c,a.shadowOffsetX=d.shadow.xOffset*c,a.shadowOffsetY=d.shadow.yOffset*c;return!0},this.setFillStyle=function(a,b){if(b instanceof CanvasImage){var c=a.createPattern(b.image,"repeat");a.fillStyle=c}else b instanceof EdenUI.plugins.Canvas2D.FillStyle?a.fillStyle=b.getColour(a):a.fillStyle=b},this.initZoneFromDrawingOpts=function(b,c){var d;if(b instanceof Object&&b.zone!==!1){if(d=b.name,void 0===d&&b.zone===!0)return root.currentObservableName();if(a.eden.isValidIdentifier(d)){var e=root.lookup(d+"_click");void 0===e.value()&&e.assign(!1,root.scope,root.lookup(c))}return d}},this.initZoneFromName=function(b,c){if(a.eden.isValidIdentifier(b)){var d=root.lookup(b+"_click");void 0===d.value()&&d.assign(!1,root.scope,root.lookup(c))}return b},this.findDrawableHit=function(a,b,c,d,e){var f=root.lookup("view_"+a+"_content").value(),g=canvases[a];if(g){var h=g.getContext("2d"),i=root.lookup("view_"+a+"_scale").value();return this.findDrawableHitInList(f,h,i,b,c,d,e)}},this.findDrawableHitInList=function(a,b,c,d,e,f,g){if(Array.isArray(a)){var h,i;f?(h=0,i=1):(h=a.length-1,i=-1);for(var j=h;f?j=0;j+=i){var k=a[j];if("object"==typeof k)if(Array.isArray(k)){var l=this.findDrawableHitInList(k,b,c,d,e,f,g);if(l)return l}else{var m=k.isHit;if(void 0!==m){if(!g&&void 0===k.name)continue;b.save();var n=k.isHit(b,c,d,e);if(b.restore(),n===!0)return k}else if(k.inverse){var o=k.inverse(d,e),l=this.findDrawableHitInList(k.items,b,c,o.x,o.y,f,g);if(void 0!==l)return l}}}}},this.findAllDrawablesHit=function(a,b,c,d){var e=root.lookup("view_"+a+"_content").value(),f=canvases[a],g=f.getContext("2d"),h=root.lookup("view_"+a+"_scale").value();return this.findAllDrawablesHitInList(e,g,h,b,c,d)},this.findAllDrawablesHitInList=function(a,b,c,d,e,f){if(!Array.isArray(a))return[];for(var g=[],h=0;h0&&(g=g.concat(m))}}}return g};var n={leftButton:!1,middleButton:!1,rightButton:!1,button4:!1,button5:!1,buttonCount:0,insideCanvas:!1,capturing:!1};this.createCommon=function(b,f){function g(){c.drawPicture(s)}function j(a){return"view_"+b+"_"+a}function l(){var b,d,e=x.value(),f=y.value(),g=e*f,h=z.value();h instanceof Point?(b=h.x,d=h.y):(b=0,d=0);var i=A.value();void 0!==i?(i=Math.ceil((A.value()+b)*g),t.width=i):f>1?t.width=Math.ceil(C.value()*f):t.width=Math.floor(C.value());var j;void 0!==B.value()?j=Math.ceil((B.value()+d)*g):f>1?j=Math.ceil(D.value()*f):(j=D.value(),void 0!==i&&i>Math.floor(C.value())&&(j-=a.scrollBarSize),j=Math.floor(j-1)),t.height=j,t.rescale=!0,c.drawPicture(s)}function m(){E?(E=!1,t.rescale=!0,c.drawPicture(s),H||(H=!0,setTimeout(m,1e3))):(l(),H=!1)}function o(a){var b=root.lookup("mouseFollow").value();root.beginAutocalcOff(),n.insideCanvas=!0;var d;switch(a.button){case 0:n.leftButton=!0,root.lookup("mousePressed").assign(!0,root.scope,Symbol.hciAgent,b),d="Left";break;case 1:n.middleButton=!0,d="Middle";break;case 2:n.rightButton=!0,d="Right";break;case 3:n.button4=!0,d="Button4";break;case 4:n.button5=!0,d="Button5";break;default:d="Unknown"}n.buttonCount=n.leftButton+n.middleButton+n.rightButton+n.button4+n.button5;var e="|";if(n.leftButton&&(e+="Left|"),n.middleButton&&(e+="Middle|"),n.rightButton&&(e+="Right|"),n.button4&&(e+="Button4|"),n.button5&&(e+="Button5|"),root.lookup("mouseButtons").assign(e,root.scope,Symbol.hciAgent,b),root.lookup("mouseButton").assign(d+" down",root.scope,Symbol.hciAgent,b),1==n.buttonCount){var f=root.lookup("mousePosition").value();root.lookup("mouseDownView").assign(s,root.scope,Symbol.hciAgent,b),root.lookup("mouseDown").assign(f,root.scope,Symbol.hciAgent,b);var g=root.lookup("view_"+s+"_scale").value(),h=root.lookup("view_"+s+"_zoom").value(),i=g*h,j=$(this).offset(),k=(a.pageX-Math.round(j.left))/i,l=(a.pageY-Math.round(j.top))/i,m=root.lookup("view_"+s+"_offset").value();m instanceof Point&&(k-=m.x,l-=m.y);var o,p=c.findDrawableHit(s,k,l,!1,!1);o=void 0===p?void 0:p.name;var q=root.lookup("mouseZone"),r=q.value();o!==r&&q.assign(o,root.scope,Symbol.hciAgent,b),root.lookup("mouseDownZone").assign(o,root.scope,Symbol.hciAgent,b)}root.endAutocalcOff()}var p,q,r={name:"*Default"},s=b,t=canvases[b];void 0===t?(p=$('
      '),p.html(''),q=p.find(".canvashtml-canvas"),t=q[0],canvases[b]=t,contents[b]=p[0],i[b]={},t.drawingQueued=!1,t.drawingInProgress=!1,t.rescale=!1):(p=$("#"+b+"-canvascontent"),q=p.find(".canvashtml-canvas"));var u=[j("content"),j("background_colour"),j("scale"),j("zoom"),j("offset"),j("canvas_right"),j("canvas_bottom"),"mousePosition","mouseButton","mouseButtons","mouseCapture","mouseCaptured","mouseDown","mouseDownView","mouseFollow","mousePressed","mouseUp","mouseWheel","mouseWheelEnabled","mouseWheelVelocity","mouseView","mouseZone","mouseVelocity"]; +t.setAttribute("data-observables",u.join(","));var v=root.lookup("view_"+s+"_content");v.addJSObserver("repaintView",g);var w=root.lookup("view_"+s+"_background_colour");void 0===w.value()&&w.assign("white",root.scope,r),w.addJSObserver("refreshView",g);var x=root.lookup("view_"+s+"_scale"),y=root.lookup("view_"+s+"_zoom"),z=root.lookup("view_"+s+"_offset"),A=root.lookup("view_"+s+"_canvas_right"),B=root.lookup("view_"+s+"_canvas_bottom"),C=root.lookup("view_"+s+"_width"),D=root.lookup("view_"+s+"_height"),E=!1,F=x.value();void 0===F&&(x.assign(1,root.scope,r),F=1),x.addJSObserver("refreshView",l);var G=y.value();void 0===G&&(y.assign(1,root.scope,r),G=1);var H=!1;y.addJSObserver("refreshView",function(a,b){Math.round(100*b);E=!0,m()});var I,J,K=z.value();K instanceof Point?(I=K.x,J=K.y):(z.assign(new Point(0,0),root.scope,r),I=0,J=0),z.addJSObserver("refreshView",l),void 0==A.value()&&A.assign(void 0,root.scope,r),A.addJSObserver("repaintView",l),void 0==B.value()&&B.assign(void 0,root.scope,r),B.addJSObserver("repaintView",l);var L=A.value();L=void 0===L?d:L*F+I;var M=B.value();M=void 0===M?e:M*F+J;var N=root.lookup("view_"+s+"_grid_visible");void 0===N.value()&&N.assign(!1,root.scope,r),N.addJSObserver("refreshView",g);var O=root.lookup("view_"+s+"_grid_spacing");return void 0===O.value()&&O.assign(20,root.scope,r),O.addJSObserver("refreshView",g),q.on("mousedown",o),q.on("mouseup",function(b){var c=root.lookup("mouseFollow").value();root.beginAutocalcOff(),n.insideCanvas=!0;var d;switch(navigator.platform.toUpperCase().indexOf("MAC")>=0&&b.ctrlKey&&(b.button=2),b.button){case 0:n.leftButton=!1,root.lookup("mousePressed").assign(!1,root.scope,Symbol.hciAgent,c),d="Left";break;case 1:n.middleButton=!1,d="Middle";break;case 2:n.rightButton=!1,d="Right";break;case 3:n.button4=!1,d="Button4";break;case 4:n.button5=!1,d="Button5";break;default:d="Unknown"}if(n.buttonCount=n.leftButton+n.middleButton+n.rightButton+n.button4+n.button5,root.lookup("mouseButton").assign(d+" up",root.scope,Symbol.hciAgent,c),0==n.buttonCount){var e=root.lookup("mousePosition").value();root.lookup("mouseButtons").assign("",root.scope,Symbol.hciAgent,c),root.lookup("mouseUp").assign(e,root.scope,Symbol.hciAgent,c),a.plugins.Canvas2D.endClick()}else{var f="|";n.leftButton&&(f+="Left|"),n.middleButton&&(f+="Middle|"),n.rightButton&&(f+="Right|"),n.button4&&(f+="Button4|"),n.button5&&(f+="Button5|"),root.lookup("mouseButtons").assign(f,root.scope,Symbol.hciAgent,c)}root.endAutocalcOff()}).on("contextmenu",function(a){navigator.platform.toUpperCase().indexOf("MAC")>=0&&a.ctrlKey&&(a.button=2,o(a)),root.lookup("mouseContextMenuEnabled").value()||(a.preventDefault(),a.stopPropagation())}).on("click",function(a){root.lookup("mouseCapture").value()&&this.requestPointerLock()}).on("dblclick",function(a){var b=root.lookup("mouseFollow").value(),c=root.lookup("mouseDoubleClicks"),d=c.value();c.assign(d+1,root.scope,Symbol.hciAgent,b)}).on("wheel",function(a){var b,d=a.originalEvent,e=D.value();b=d.deltaMode==WheelEvent.DOM_DELTA_LINE?c.defaultLineHeight:d.deltaMode==WheelEvent.DOM_DELTA_PAGE?0!=d.deltaX?C.value():e:1;var f=root.lookup("mouseFollow").value();if(0!=d.deltaY&&a.ctrlKey&&!a.altKey&&!a.metaKey&&!a.shiftKey){a.preventDefault(),a.stopPropagation(),root.beginAutocalcOff();var g=-d.deltaY*b;if(root.lookup("touchPinchEnabled").value()){var h=root.lookup("touchPinch"),i=h.value();i+=g,h.assign(i,root.scope,Symbol.hciAgent,f)}else{var j=y.value();j=j*(e+2*g)/e,j<.05&&(j=.05),y.assign(j,root.scope,Symbol.hciAgent,f)}return void root.endAutocalcOff()}if(root.lookup("mouseWheelEnabled").value()){if(root.beginAutocalcOff(),0!==d.deltaY&&(!a.ctrlKey||a.altKey||a.metaKey||a.shiftKey)){a.preventDefault(),a.stopPropagation();var k=root.lookup("mouseWheel"),l=k.value(),g=d.deltaY*b;l+=g,k.assign(l,root.scope,Symbol.hciAgent,f),root.lookup("mouseWheelVelocity").assign(g,root.scope,Symbol.hciAgent,f)}if(0!==d.deltaX){a.preventDefault(),a.stopPropagation();var m=root.lookup("touchPanX"),n=m.value(),o=d.deltaX*b;n+=o,m.assign(n,root.scope,Symbol.hciAgent,f),root.lookup("touchPanXSpeed").assign(o,root.scope,Symbol.hciAgent,f)}root.endAutocalcOff()}}).on("mouseout",function(a){n.insideCanvas=!1;var b=root.lookup("mouseFollow").value();root.lookup("mouseZone").assign(void 0,root.scope,Symbol.hciAgent,b)}).on("mouseenter",function(a){if(!n.insideCanvas){n.insideCanvas=!0;var b;0==n.buttonCount?b="":(b="|",n.leftButton&&(b+="Left|"),n.middleButton&&(b+="Middle|"),n.rightButton&&(b+="Right|"),n.button4&&(b+="Button4|"),n.button5&&(b+="Button5|"));var c=root.lookup("mouseButtons"),d=c.value();if(b!=d){var e=root.lookup("mouseFollow").value();root.beginAutocalcOff(),c.assign(b,root.scope,Symbol.hciAgent,e),root.lookup("mouseButton").assign("Enter window",root.scope,Symbol.hciAgent,e);var f=root.lookup("mousePressed");f.value()!=n.leftButton&&f.assign(n.leftButton,root.scope,Symbol.hciAgent,e),""==d&&""!=b&&(root.lookup("mouseDown").assign(void 0,root.scope,Symbol.hciAgent,e),root.lookup("mouseDownView").assign(void 0,root.scope,Symbol.hciAgent,e)),root.endAutocalcOff()}}}).on("mousemove",function(a){k=!0;var b=root.lookup("mouseFollow").value();root.beginAutocalcOff();var d,e,f,g,i=root.lookup("mouseView"),j=root.lookup("mousePosition"),l=i.value(),m=j.value();m&&(f=m.x,g=m.y);var o=root.lookup("view_"+s+"_scale").value(),p=root.lookup("view_"+s+"_zoom").value(),q=o*p;if(n.capturing){var r=a.originalEvent;d=f+r.movementX/q,e=g+r.movementY/q}else{var t=$(this).offset();d=(a.pageX-Math.round(t.left))/q,e=(a.pageY-Math.round(t.top))/q;var u=root.lookup("view_"+s+"_offset").value();u instanceof Point&&(d-=u.x,e-=u.y)}i.assign(s,root.scope,Symbol.hciAgent,b);var v=new Point(d,e);j.assign(v,root.scope,Symbol.hciAgent,b);var w,x=Date.now();if(l==s&&void 0!==h){if(w=x-h,w>=c.mouseVelocitySampleTime){var y=root.lookup("mouseVelocity"),z=y.value(),A=1e3*(d-f)/w,B=1e3*(e-g)/w;if(z){var C=c.mouseVelocityDampening,D=z.x;(A>0&&D>0||A<0&&D<0)&&(A=C*D+(1-C)*A);var E=z.y;(B>0&&E>0||B<0&&E<0)&&(B=C*E+(1-C)*B)}A=Math.ceil(A*q)/q,B=Math.ceil(B*q)/q;var F=new Point(A,B);y.assign(F,root.scope,Symbol.hciAgent,b),h=x}}else h=x;var G,H=c.findDrawableHit(s,d,e,!1,!1);G=void 0===H?void 0:H.name;var I=root.lookup("mouseZone"),J=I.value();G!==J&&I.assign(G,root.scope,Symbol.hciAgent,b),root.endAutocalcOff()}).on("keyup",function(a){var b=a.which,c=!1;if(a.altKey&&!a.shiftKey&&!a.ctrlKey){var d=root.lookup("view_"+s+"_zoom"),e=d.value();61==b||187==b?(e=1.25*e,c=!0):173==b||189==b?(e/=1.25,c=!0):48==b&&(e=1,c=!0),d.assign(e,root.scope,Symbol.hciAgent)}c&&(a.preventDefault(),a.stopPropagation())}),{initialWidth:L,initialHeight:M,code_entry:p,offsetSym:z,zoomSym:y,widthSym:A,heightSym:B,scaleSym:x}},this.createEmbedded=function(b,d,e){var f=b;eden.execute2("view_"+f+"_content is "+e+";");var g=c.createCommon(b,d),h=(g.initialWidth,g.initialHeight,g.code_entry),i=g.offsetSym,j=g.zoomSym,k=g.widthSym,l=g.heightSym,m=g.scaleSym,n={code_entry:h,contents:h,destroy:function(){delete canvases[f],delete contents[f]},resize:function(b,d){var e,g,h=i.value();h instanceof Point?(e=h.x,g=h.y):(e=0,g=0);var n,o,p=j.value(),q=document.getElementById(f+"-canvas"),r=!1,s=k.value();if(void 0===s?(n=p>1?Math.ceil(b*p):Math.floor(b),q.width!=n&&(q.width=n,r=!0)):s=Math.ceil(s*m.value()*p+e),void 0===l.value()){if(p>1)o=Math.ceil(d*p);else{o=d,void 0!==s&&s>o&&(o-=a.scrollBarSize);var o=Math.floor(o-1)}o!=q.height&&(q.height=o,r=!0)}r&&c.drawPicture(f)}};return n},this.createDialog=function(b,d){var e,f=b.slice(0,-7),g=c.createCommon(f,d),h=g.initialWidth,j=g.initialHeight,k=g.code_entry,l=g.offsetSym,m=g.zoomSym,n=g.widthSym,o=g.heightSym,p=g.scaleSym;return $('
      ').html(k).dialog({appendTo:"#jseden-views",title:d,width:h+a.scrollBarSize,height:j+a.titleBarHeight,minHeight:120,minWidth:230,classes:{"ui-dialog":"canvas-dialog unpadded-dialog ui-front"}}),e={confirmClose:!0,destroy:function(){var a=i[f];for(var b in a)for(var c=a[b],d=0;d1?Math.ceil(b*k):Math.floor(b),q.width!=i&&(q.width=i,r=!0)):s=Math.ceil(s*p.value()*k+e),void 0===o.value()){if(k>1)j=Math.ceil(d*k);else{j=d,void 0!==s&&s>j&&(j-=a.scrollBarSize);var j=Math.floor(j-1)}j!=q.height&&(q.height=j,r=!0)}r&&c.drawPicture(f)}},c.drawPicture(f),e},root.lookup("mouseDownZone").addJSObserver("recordClick",function(a,b){if(eden.isValidIdentifier(b)){var c=root.lookup(b+"_click");c.value()===!1&&c.assign(!0,root.scope,Symbol.hciAgent,!0)}}),this.endClick=function(){var a=root.lookup("mouseDownZone").value();if(eden.isValidIdentifier(a)){var b=root.lookup(a+"_click");b.value()===!0&&b.assign(!1,root.scope,Symbol.hciAgent,!0)}},this.canvasNameFromElement=function(a){for(;a;){var b=a.id;if("-canvascontent"==b.slice(-14))return b.slice(0,-14);a=a.parentElement}return null},document.addEventListener("mouseup",function(b){var c=root.lookup("mouseFollow").value();if(root.beginAutocalcOff(),!n.insideCanvas){var d;switch(b.button){case 0:n.leftButton=!1,d="Left";break;case 1:n.middleButton=!1,d="Middle";break;case 2:n.rightButton=!1,d="Right";break;case 3:n.button4=!1,d="Button4";break;case 4:n.button5=!1,d="Button5";break;default:d="Unknown"}n.buttonCount=n.leftButton+n.middleButton+n.rightButton+n.button4+n.button5;var e=root.lookup("mouseButtons");if(0==n.buttonCount&&""!=e.value()){var f=root.lookup("mousePressed"),g=f.value();root.lookup("mouseButton").assign(d+" up",root.scope,Symbol.hciAgent,c),e.assign("",root.scope,Symbol.hciAgent,c),root.lookup("mousePosition").assign(void 0,root.scope,Symbol.hciAgent,c),g&&f.assign(!1,root.scope,Symbol.hciAgent,c),root.lookup("mouseUp").assign(void 0,root.scope,Symbol.hciAgent,c),root.lookup("mouseView").assign(void 0,root.scope,Symbol.hciAgent,c),a.plugins.Canvas2D.endClick()}}root.endAutocalcOff()}),document.addEventListener("mousedown",function(a){if(!n.insideCanvas){switch(a.button){case 0:n.leftButton=!0;break;case 1:n.middleButton=!0;break;case 2:n.rightButton=!0;break;case 3:n.button4=!0;break;case 4:n.button5=!0}n.buttonCount=n.leftButton+n.middleButton+n.rightButton+n.button4+n.button5}}),document.addEventListener("pointerlockchange",function(a){var b=null!==document.pointerLockElement;n.capturing=b;var c=root.lookup("mouseFollow").value();root.lookup("mouseCaptured").assign(b,root.scope,void 0,c)}),a.views.Canvas2D={dialog:this.createDialog,embedded:this.createEmbedded,title:"Canvas 2D",category:a.viewCategories.visualization,holdsContent:!0};var o;o="/index-dev.html"==document.location.pathname.slice(-15)?"canvas.js-e":"jseden-canvas.min.js-e",Eden.Selectors.execute("plugins > canvas > canvas",function(){eden.root.lookup("plugins_canvas_loaded").assign(!0,eden.root.scope),b&&b()})},EdenUI.plugins.Canvas2D.FillStyle=function(){},EdenUI.plugins.Canvas2D.Transform=function(){},EdenUI.plugins.Canvas2D.Transform.CSSInfo=function(a,b,c){this.css=a,this.scaleX=b,this.scaleY=c},EdenUI.plugins.Canvas2D.title="Canvas 2D",EdenUI.plugins.Canvas2D.description="Provides the ability to draw two-dimensional shapes, images, text and user interface controls using EDEN dependencies.",EdenUI.plugins.Page=function(a,b){function c(a){if(!a)return"";if("title"!=a[0])return"";var b,c=$("
      "),d=$("
      ");a[6]&&c.css("height",""+a[6]+"px"),b=a[1]?$(""+a[1]+""):$('');var e=$("
      "+a[2]+"");return d.append(b),d.append(e),c.append(d),void 0!==a[3],c}function d(a){if(!a)return"";if("header"!=a[0])return"";switch(a[3]){case 0:return $("

      "+a[1]+"

      ");case 1:return $("")}}function e(a){var b=typeof a;switch(b){case"string":return a;case"number":return""+a+"px";default:return""}}function f(a,b){for(var c=0;c]*(?:"[^"]*")*(?:'[^']*')*)*)?(?:\/|(?:>((?:[^<]*(?:<(?!\/jseden\1>))*)*)<\/jseden\1))>/g,function(a,d,e,f,h,i,j){return void 0===h&&(h=""),b.push(h),c.push(g(e,f)),"\0\0"});var d=a.split("\0\0");if(1==d.length)return a;for(var e=$("
      "),f=0;f"+d[f]+"
      ")),void 0===c[f].tagType){var h=b[f].split("\n").length;void 0===c[f].lines&&(c[f].lines=h),void 0===c[f].width&&(c[f].width="50%"),void 0===c[f].box&&(c[f].box=!0);var i=l(["script",c[f].static,[b[f]],c[f].name,c[f].box,c[f].lines,!1,c[f].float,c[f].width]);e.append(i)}else if(c[f])if("canvas"==c[f].tagType){var j=n(["canvas",c[f].name,c[f].source,c[f].width,c[f].height,c[f].float,c[f].box]);e.append(j)}else if("veden"==c[f].tagType){var k=m(["veden",c[f].name,c[f].width,c[f].height,c[f].float,b[f]]);e.append(k)}return e.append($("
      "+d[d.length-1]+"
      ")),e.get(0)}function i(a){if(a&&"element"==a[0]){var b,c=a[1],d=a[2],e=a[3],g=a[4],i=a[5],k=a[6],l=(a[7],a[8],a[9],a[10],a[11],a[12]),m=a[13];switch(c){case"div":case"span":case"button":case"img":case"p":case"ul":case"ol":case"li":case"br":case"pre":case"h1":case"h2":case"h3":case"a":case"input":b=document.createElement(c);break;default:return void console.error("Invalid element type: "+c)}if(d&&(b.id=d),e&&(b.className=e),g&&"string"==typeof g){var n=h(g);"string"==typeof n?b.innerHTML=n:b.appendChild(n)}return g&&g instanceof Array&&j(b,g),i&&"string"==typeof i&&(b.cssText=i),i&&i instanceof Array&&f(b,i),k&&d&&(b.onclick=function(a){var b=eden.root.lookup(d+"_click");console.log("ELEMENT CLICK"),b.assign(!0,eden.root.scope)}),"img"==c&&l&&(b.src=l),"a"==c&&m&&(b.href=m),b}}function j(a,b){if("string"==typeof b[0]){var c=i(b);return void(c&&a.appendChild(c))}for(var d=0;d([\s\S]*?)<\/jseden>/g,function(a,b,d,e,f){return console.log("ATTRIBS: "+b),c.push(d),"\0\0"});var d=b.split("\0\0");if(1==d.length)return $("
      "+b+"
      ");for(var e=$("
      "+d[f]+"
      "));var g=c[f].split("\n").length,h=l(["script",!1,[c[f]],void 0,!0,g,!1,!1,"50%"]);e.append(h)}return e.append($("
      "+d[d.length-1]+"
      ")),e}function l(b){if(b&&"script"==b[0]){var c=b[1],d=b[2],e=b[3],f=b[4],g=b[5],h=b[6],i=b[7],j=b[8];if(void 0===e&&(e="embedded"+B,B++),c){var k;k=f?$("
      "):$("
      ");var l,m=new EdenUI.Highlight(k.get(0));l=d instanceof Array?EdenUI.plugins.ScriptInput.buildScriptFromList(d):d;var n=new Eden.AST(l);m.highlight(n,-1,-1),i&&"none"!=i&&k.css("float",i),"50%"!=j&&("number"==typeof j?k.width(j):k.css("width",j));var o=EdenUI.plugins.ScriptInput.getRequiredHeight(g,!0);return k.height(o),k}var p;z[e]?(p=z[e],p.update(d)):(p=a.views.ScriptInput.embed(e,e,d,h),z[e]=p);var q;q=f?$("
      "):$("
      ");var o=EdenUI.plugins.ScriptInput.getRequiredHeight(g,!0);return q.height(o),i&&"none"!=i&&q.css("float",i),"50%"!=j&&("number"==typeof j?q.width(j):q.css("width",j)),p.contents.appendTo(q),q.resizable(),q}}function m(b){if(b&&"veden"==b[0]){var c,d=b[1],e=b[2],f=b[3],g=b[4],h=b[5];A[d]?c=A[d]:(c=a.views.Veden.embed(d,d,h),A[d]=c);var i;return i=$("
      "),i.height(f),g&&"none"!=g&&i.css("float",g),"50%"!=e&&("number"==typeof e?i.width(e):i.css("width",e)),c.contents.appendTo(i),i.resizable(),i}}function n(b){var c,d=b[6],f=b[3],g=b[4];if(c=d?$("
      "):$("
      "),f&&c.css("width",e(f)),g&&c.css("height",e(g)),void 0===y[b[1]]){var h=a.views.Canvas2D.embedded(b[1],b[1],b[2]);y[b[1]]=h,c.append(h.code_entry),x.push(function(){h.resize(b[3],b[4])})}else y[b[1]].code_entry.appendTo(c),x.push(function(){y[b[1]].resize(b[3],b[4])});return"none"!=b[5]&&c.css("float",b[5]),c}function o(a){var b;if(b=a[1]?$("
        "):$("
          "),a[2]&&a[2]instanceof Array)for(var c=0;c"+a[2][c]+"");b.append(d)}return b}function p(a,b){if(!a)return"";if(!(a instanceof Array))return"";for(var c=$("
          "),e=0;e"));break;case"list":c.append(o(a[e]))}return c}function q(a,b){if(void 0!==b&&b instanceof Array){for(var c in y)y[c].code_entry.detach();for(var d in z)z[d].contents.detach();w.html(""),j(w.get(0),b);for(var e=0;e");$("#jseden-views").append(w).addClass("page-body");var x=[],y={},z={},A={},B=0,C=["top","bottom","left","right","width","height","background","position","color","border","font","fontSize","fontFamily","fontWeight","borderBottom","borderLeft","borderRight","borderTop","overflow","padding","paddingTop","paddingLeft","paddingRight","paddingBottom","margin","marginLeft","marginRight","marginTop","marginBottom","textShadow"];r(t,v),t.addJSObserver("pageGenerator",r),u.addJSObserver("pageGenerator",q),Eden.Selectors.execute("plugins > page > page",function(){eden.root.lookup("plugins_page_loaded").assign(!0,eden.root.scope),b&&b()})},EdenUI.plugins.Page.title="Page",EdenUI.plugins.Page.description="Generate web content from scripts.";var edenfunctions={};EdenUI.plugins.SymbolViewer=function(a,b){var c=this;this.instances=[];var d=0,e=function(a,b){var c='\t\t\t
          \t\t\t\t \t\t\t\tEdit Listed
          \t\t\t\t';return c+='\t\t\t
          \t\t\t
          '};this.createDialog=function(b,f,g){function h(){var b=q.value();return o.val().startsWith("select: ")?a.regExpFromStr("","",!1,b):a.regExpFromStr(o,"",!1,b)}function i(a,b){n.search(p.value,h()),"regexp"==b?o.attr("placeholder","search regular expression"):"simple"==b?o.attr("placeholder","simple search"):o.attr("placeholder","search")}var k=b.slice(0,-7),l=root.lookup("createView"),m=$('
          ');m.html(e(b,g));var n=new EdenUI.plugins.SymbolViewer.SymbolList(a.eden.root,m.find(".symbollist-results")[0],g);$dialog=$('
          ').append(m).dialog({appendTo:"#jseden-views",title:f,width:360,height:400,minHeight:200,minWidth:200,classes:{"ui-dialog":"symbollist-dialog ui-front"}}),c.instances.push(n),d++,1==d&&a.eden.root.addGlobal(j),m.find(".symbollist-search-box-outer > .symbollist-edit").click(function(){var b="edit_"+k;if(p.value.startsWith("select: ")){a.createView(b,"ScriptInput",void 0);var c=eden.root.lookup("view_"+b+"_tabs").value();Array.isArray(c)||(c=[]),c.push(p.value.substring(8)),eden.root.lookup("view_"+b+"_tabs").assign(c,eden.root.scope,Symbol.hciAgent),eden.root.lookup("view_"+b+"_current").assign(c.length-1,eden.root.scope,Symbol.hciAgent)}});var o=m.find(".symbollist-search-box-outer > .symbollist-search"),p=o[0],q=root.lookup("view_"+k+"_search_language");i(q,q.value()),q.addJSObserver("refreshView",i);var r=root.lookup("view_"+k+"_search_string"),s=function(a,b){void 0!==b&&(b!==p.value&&(p.value=b),n.search(b,h()))},t=r.value();void 0===t?(r.assign("",root.scope,l),n.search("",new RegExp(""))):s(r,t),r.addJSObserver("refreshView",s),o.keyup(function(){r.assign(p.value,root.scope,Symbol.hciAgent)});var u={destroy:function(){var b=c.instances.indexOf(n);c.instances.splice(b,1),d--,0==d&&a.eden.root.removeGlobal(j)}};return u},this.createObservableDialog=function(a,b){return c.createDialog(a,b,"obs")},this.createFunctionDialog=function(a,b){return c.createDialog(a,b,"func")},this.createAgentDialog=function(a,b){return c.createDialog(a,b,"agent")},this.createSymbolDialog=function(a,b){return c.createDialog(a,b,"all")};var f={},g={},h=!1;this.isCreationPending=function(a){return a in g},this.delay=40;var i=function(){for(x in c.instances){var a,b,d,e=c.instances[x];void 0===EdenUI.plugins.SymbolViewer.inlineEditorSymbol&&(a=$(e.symresults),b=a.parent(),d=a.scrollTop(),a.detach());for(var i in g){var j=g[i];e.filter?e.filter.indexOf(i)>=0&&e.addSymbol(j,i):e.addSymbol(j,i)}for(var i in f)e.updateSymbol(i);void 0===EdenUI.plugins.SymbolViewer.inlineEditorSymbol&&(a.appendTo(b),a.scrollTop(d))}f={},g={},h=!1},j=function(a,b){var d=a.name;if(1==b)g[d]=a;else{if(d in g)return;f[d]=a}h||(h=!0,setTimeout(i,c.delay))};a.views.ObservableList={dialog:this.createObservableDialog,title:"Observable List",category:a.viewCategories.comprehension,menuPriority:0},a.views.FunctionList={dialog:this.createFunctionDialog,title:"Function List",category:a.viewCategories.comprehension,menuPriority:0},a.views.AgentList={dialog:this.createAgentDialog,title:"Agent List",category:a.viewCategories.comprehension,menuPriority:0},a.views.SymbolList={dialog:this.createSymbolDialog,title:"Symbol List",category:a.viewCategories.comprehension,menuPriority:1},eden.root.lookup("plugins_symbolviewer_loaded").assign(!0,eden.root.scope),b()},EdenUI.plugins.SymbolViewer.title="Symbol Viewer",EdenUI.plugins.SymbolViewer.description="Provide various views of the symbol table.",EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0,EdenUI.plugins.SymbolViewer.SymbolList=function(a,b,c){this.root=a,this.regExp=new RegExp(""),this.type=c,this.category="all",this.customCategory=!1,this.subtypes="all",this.symresults=b,this.symbols={},this.filter=void 0},EdenUI.plugins.SymbolViewer.SymbolList.prototype.search=function(a,b,c,d){if("undefined"!=typeof a)if(a.startsWith("select: ")){var e=Eden.Selectors.query(a.substr(8),"symbol");console.log(e),this.filter=e,this.regExp=b,this.regExp=b,void 0!==d&&(this.subtypes=d),EdenUI.closeTooltip(),this.symresults.innerHTML="",this.symbols={};for(var f=0;f'),d&&this.element.addClass("symbollist-"+d+"-result"),c){case"func":this.update=this.updateFunction;break;case"agent":this.update=this.updateProcedure;break;case"obs":this.update=this.updateObservable}var f=this,g=!1;this.element.click(function(){EdenUI.plugins.SymbolViewer.inlineEditorSymbol||g||(g=!0,setTimeout(function(){if(!EdenUI.plugins.SymbolViewer.inlineEditorSymbol&&g){g=!1;"edit_"+f.name;Eden.Selectors.goto("> :not(ACTIVE) >> "+a.name)}},350))}),"obs"==c&&this.element.dblclick(function(){function a(){var a=l.get(0).value,b=o.value;";"!=b.slice(-1)&&(b+=";"),eden.execute2(f.name+" "+a+" "+b),e(),EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0}function c(b){var c=b.which;13==c?a():27==c&&(e(),EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0)}if(g=!1,EdenUI.plugins.SymbolViewer.inlineEditorSymbol!==f){var d=f.symbol.cache.value;if(void 0!==f.symbol.definition||"boolean"!=typeof d){EdenUI.plugins.SymbolViewer.inlineEditorSymbol=f,f.element.addClass("symbollist-inline-editor");var h=f.element.find(".result_value"),i=f.element.find(".result_separator");h.html("");var j,k;void 0!==f.symbol.definition?(j=f.symbol.getSource().replace(new RegExp("^\\s*"+b+"\\s+is\\s+"),""),k="is"):(j=Eden.edenCodeForValue(d),k="=");var l=$("");"="==k?(l.append(''),l.append('')):(l.append(''),l.append('')),i.html(" "),i.append(l);var m=Eden.htmlEscape(j,!0),n=$(''),o=n.get(0);n.on("keyup",c),n.on("blur",function(){setTimeout(function(){l.is(document.activeElement)||(e(),setTimeout(function(){EdenUI.plugins.SymbolViewer.inlineEditorSymbol===f&&(EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0)},500))},0)}),l.on("keydown",c),l.on("blur",function(){setTimeout(function(){n.is(document.activeElement)||(e(),setTimeout(function(){EdenUI.plugins.SymbolViewer.inlineEditorSymbol===f&&(EdenUI.plugins.SymbolViewer.inlineEditorSymbol=void 0)},500))},0)}),h.append(n);var p=f.element.find(".symbollist-result-inner");p.length>0&&(p.get(0).onmouseenter=void 0),EdenUI.closeTooltip(),o.focus(),o.select();var q=j.slice(0,1);'"'!=q&&"'"!=q&&"["!=q&&"{"!=q||(o.selectionStart=1,o.selectionEnd=j.length-1)}else d===!0?f.symbol.assign(!1,eden.root.scope,Symbol.hciAgent,!0):f.symbol.assign(!0,eden.root.scope,Symbol.hciAgent,!0)}}),this.update()},EdenUI.plugins.SymbolViewer.Symbol.prototype.updateFunction=function(){var a,b,c=this.symbol.getSource();if(a=void 0===this.symbol.definition||/^func\s/.test(c)?this.name:""+this.name+"",void 0!=edenfunctions.functions&&void 0!==edenfunctions.functions[this.name]){this.details=edenfunctions.functions[this.name];var d=Object.keys(this.details.parameters||{});b="( "+d.join(", ")+" )"}else b="";var e=""+a+""+b;if(void 0!==this.symbol.definition&&!/^func\s/.test(this.symbol.eden_definition)){var f=Eden.htmlEscape(c,!1,!0);f=Eden.htmlEscape("
          "+f+";
          "),e=""+e+""}this.element.html(e)},EdenUI.plugins.SymbolViewer.Symbol.prototype.updateObservable=function(){var a,b=this.symbol.value(),c=_formatVal(b);a=void 0!==this.symbol.definition?""+this.name+"":this.name;var d=""+a+" = "+c+"";if(void 0!==this.symbol.definition){var e=Eden.htmlEscape(this.symbol.getSource(),!1,!0);e=Eden.htmlEscape("
          "+e+";
          "),d=""+d+""}this.element.html(d)},EdenUI.plugins.SymbolViewer.Symbol.prototype.updateProcedure=function(){var a,b,c=this.symbol.getSource();if(a=void 0===this.symbol.definition||/^proc\s/.test(c)?this.name:""+this.name+"",void 0!=edenfunctions.functions&&void 0!==edenfunctions.procedures[this.name]){this.details=edenfunctions.procedures[this.name];var d=Object.keys(this.details.parameters||{});b="( "+d.join(", ")+" )"}else b="";var e=""+a+""+b;if(void 0!==this.symbol.definition&&!/^proc\s/.test(c)){var f=Eden.htmlEscape(c,!1,!0);f=Eden.htmlEscape("
          "+f+";
          "),e=""+e+""}this.element.html(e)};var edenfunctions={};EdenUI.plugins.VersionViewer=function(a,b){var c=this;this.instances=[];var d=0,e=function(a,b){var c='
          ';return c};this.createDialog=function(b,f,g){var h=b.slice(0,-7),i=(root.lookup("createView"),$('
          '));i.html(e(b,g)),$dialog=$('
          ').append(i).dialog({appendTo:"#jseden-views",title:f,width:360,height:400,minHeight:200,minWidth:200,classes:{"ui-dialog":"versionviewer-dialog ui-front"}});var j=(root.lookup("view_"+h+"_search_string"),function(){var a=URLUtil.getParameterByName("load");$.get(Eden.DB.remoteURL+"/project/versions",{projectID:a},function(b){var c=i.find(".version-viewer-list").html(""),d=$("VidDateParentDiff");c.append(d),$(b).each(function(b,d){var e=$(''+d.saveID+""+d.date+""+d.parentDiff+"");c.append(e)})})});j();var k={destroy:function(){var b=c.instances.indexOf(symbollist);c.instances.splice(b,1),d--,0==d&&a.eden.root.removeGlobal(symbolChanged)}};return k},this.createVersionListDialog=function(a,b){return c.createDialog(a,b,"all")},a.views.VersionList={dialog:this.createVersionListDialog,title:"Version List",category:a.viewCategories.history,menuPriority:1},eden.root.lookup("plugins_VersionViewer_loaded").assign(!0,eden.root.scope),b()},EdenUI.plugins.VersionViewer.title="Version Viewer",EdenUI.plugins.VersionViewer.description="Show version details for a specified project.",EdenUI.plugins.VersionViewer.inlineEditorSymbol=void 0,EdenUI.plugins.ExternalHTMLContent=function(a,b){function c(){d=!1}var d=!1,e=!1;this.createDialog=function(b,f){function g(a,b){void 0===b?n.src="plugins/external-html-content/undefined-url.html?view="+encodeURI(j):n.src="plugins/external-html-content/redirect.html?view="+encodeURI(j)+"&url="+encodeURI(b)}function h(a,b){b?(r.value()&&l.addClass("external-html-content-pinned"), +p.css("display","block")):(l.removeClass("external-html-content-pinned"),p.css("display","none"))}function i(a,b){q.value()&&l.toggleClass("external-html-content-pinned",b)}e||(""==document.location.hash&&window.history.pushState({},"","#noNavigateAway"),window.addEventListener("popstate",function(){""==document.location.hash&&(d?window.history.forward(1):a.modalDialog("Leave Environment?","

          Leaving this page will discard the current script. Your work will not be saved.

          Are you sure you want to close JS-EDEN?

          ",["Close JS-EDEN","Return to Construal"],1,function(a){0==a?(doingNavigateAway=!0,window.history.back(1)):window.history.forward(1)}))}),e=!0);var j=b.slice(0,-7),k=root.lookup("createView"),l=$(''),m=root.lookup("_view_"+j+"_url"),n=l[0];g(m,m.value()),m.addJSObserver("refreshView",g);var o=$('
          ').html(l).dialog({title:f,width:600,height:450,minHeight:120,minWidth:230,dialogClass:"external-html-content"}),p=$('
          ');o.append(p);var q=root.lookup("_view_"+j+"_toolbar_visible"),r=root.lookup("_view_"+j+"_toolbar_pinned");void 0===q.value()&&q.assign(!0,root.scope,k),void 0===r.value()&&r.assign(!1,root.scope,k),h(q,q.value()),q.addJSObserver("refreshView",h),r.addJSObserver("refreshView",i);var s=$('');s.on("click",function(){r.assign(!r.value(),root.scope,Symbol.hciAgent),n.focus()}),p.append(s);var t=$('');t.on("click",function(){d||setTimeout(c,1e3),d=!0,window.history.back(1),n.focus()}),p.append(t);var u=$('');u.on("click",function(){window.history.forward(1),n.focus()}),p.append(u);var v=$('');return v.on("click",function(){g(m,m.value()),n.focus()}),p.append(v),{confirmClose:!0}},a.views.ExternalHTMLContent={dialog:this.createDialog,title:"External HTML Content",category:a.viewCategories.visualization,holdsContent:!0},a.eden.include("plugins/external-html-content/external-html-content.js-e",b)},EdenUI.plugins.ExternalHTMLContent.title="External HTML Content",EdenUI.plugins.ExternalHTMLContent.description="Allows construals to display web pages created outside of JS-EDEN.",EdenUI.plugins.HTMLContent=function(a,b){this.createDialog=function(a,b){function c(a){return"view_"+e+"_"+a}function d(a,b){k.get(0).parentNode.style.background=b}var e=a.slice(0,-7),f=[c("background_colour"),c("content")],g=$('
          ');g.on("mousedown","button",function(a){var b=a.currentTarget.name,c=a.currentTarget.getAttribute("data-value");null!==c&&null!==c.charAt(0).match(/[0-9]?/)&&(c=parseInt(c)),eden.root.lookup(b).assign(null===c||c,eden.root.scope,Symbol.hciAgent)}),g.on("mouseup","button",function(a){var b=a.currentTarget.name,c=a.currentTarget.getAttribute("data-value");null===c&&eden.root.lookup(b).assign(!1,eden.root.scope,Symbol.hciAgent)}),g.on("click",function(a){var b=a.srcElement.getAttribute("data-jseden");b&&""!=b&&(console.log(b),eden.execute2(b,{name:"execute"}))});var h=root.lookup("view_"+e+"_content"),i=function(a,b){void 0===b?g.html('
          Give view_'+e+"_content a value to display HTML formatted text here.
          "):g.html(b)};i(h,h.value()),h.addJSObserver("repaintView",i);var j=root.lookup("view_"+e+"_background_colour");j.addJSObserver("changeColour",d);var k=$('
          ').html(g).dialog({appendTo:"#jseden-views",title:b,width:600,height:450,minHeight:120,minWidth:230,classes:{"ui-dialog":"htmlviews-dialog ui-front"}}),l=j.value();return l&&d(j,l),{confirmClose:!0}},a.views.HTMLContent={dialog:this.createDialog,title:"HTML Content",category:a.viewCategories.visualization,holdsContent:!0},Eden.Selectors.execute("plugins > html > html",function(){eden.root.lookup("plugins_html_loaded").assign(!0,eden.root.scope,Symbol.localJSAgent),b&&b()})},EdenUI.plugins.HTMLContent.title="HTML Content",EdenUI.plugins.HTMLContent.description="Provides construals with the ability to create windows dedicated to displaying HTML content created using EDEN code.",EdenUI.plugins.ExpressionTree=function(a,b){var c=this;this.createDialog=function(a,b){var c='
          ';$dialog=$('
          ').html(c).dialog({title:b,width:300,height:450,minHeight:120,minWidth:230})};var d=function(a,b,c,d,e){var f=function(g,h,i){if(!g.hasOwnProperty("children"))return g.name;var j,k,l,m=g.name,n=g.children;if(b.hasOwnProperty(m)&&2==n.length){j=b[m],k=j.precedence;var o=j.associativity,p=f(n[0],k,j.text),q=f(n[1],k,j.text);if("left"==o){var r=n[1].name;n[1].hasOwnProperty("children")&&2==n[1].children.length&&b.hasOwnProperty(r)&&k==b[r].precedence&&(q="("+q+")")}else{var s=n[0].name;n[0].hasOwnProperty("children")&&2==n[0].children.length&&b.hasOwnProperty(s)&&k==b[s].precedence&&(p="("+p+")")}l=j.whitespace?p+" "+j.text+" "+q:p+j.text+q}else if(a.hasOwnProperty(m))j=a[m],k=j.precedence,l=j.text+f(n[0],k,j.text);else if(c.hasOwnProperty(m))j=c[m],k=j.precedence,l=f(n[0],k,j.text)+j.text;else if(d.hasOwnProperty(m))j=d[m],this.precedence=j.precedence,l=j.code(n,i);else{k=e;for(var t=[],u=0;u"]={precedence:6,associativity:"left",text:">=",whitespace:!0},e[">="]={precedence:6,associativity:"left",text:">",whitespace:!0},e["=~"]={precedence:6,associativity:"left",text:"=~",whitespace:!0},e["!~"]={precedence:6,associativity:"left",text:"!=",whitespace:!0},e["//"]={precedence:7,associativity:"left",text:"//",whitespace:!0},e["+"]={precedence:8,associativity:"left",text:"+",whitespace:!0},e["-"]={precedence:8,associativity:"left",text:"-",whitespace:!0},e["*"]={precedence:9,associativity:"left",text:"*",whitespace:!0},e["/"]={precedence:9,associativity:"left",text:"/",whitespace:!0},e["%"]={precedence:9,associativity:"left",text:"%",whitespace:!0},e["^"]={precedence:11,associativity:"right",text:".",whitespace:!1},e["."]={precedence:14,associativity:"left",text:".",whitespace:!1};var f={};f["-"]={precedence:10,text:"-"},f["!"]={precedence:10,text:"!"},f["&"]={precedence:10,text:"&"},f.not={precedence:10,text:"!"},f["++."]={precedence:11,text:"++"},f["--."]={precedence:11,text:"--"},f["*"]={precedence:12,text:"*"};var g={};g["#"]={precedence:11,text:"#"},g[".++"]={precedence:11,text:"++"},g[".--"]={precedence:11,text:"--"};var h={},i=13;this.convertTreeToEden=d(f,e,g,h,i),h["?"]={precedence:2,code:function(a){var b=c.convertTreeToEden(a[0]),d=c.convertTreeToEden(a[1]),e=c.convertTreeToEden(a[2]);return b+"? "+d+" : "+e}},h["`...`"]={precedence:13,code:function(a){var b=c.convertTreeToEden(a[0]);return"`"+b+"`"}},h["${{...}}$"]={precedence:13,code:function(a){var b=a[0].name;return"${{ "+b+" }}$"}},h["(...)"]={precedence:13,code:function(a){for(var b=c.convertTreeToEden(a[0]),d=[],e=1;e'+c(a)+"
          "),$dialog=$('
          ').html(code_entry).dialog({title:b,width:600,height:450,minHeight:120,minWidth:230})},a.views.SymbolLookUpTable={dialog:this.createDialog,title:"Symbol Look-Up Table",category:a.viewCategories.comprehension,menuPriority:3},this.search=function(b){var c=$("#"+b+"-regexp"),e=a.regExpFromStr(c);document.getElementById(b+"-table-div").innerHTML=d(e,b)};var c=function(a){var b="",c="
          "+b+"
          "+d(new RegExp(""),a)+"
          ";return c},d=function(a,b){var c='NameTypeDefinitionCurrent ValueWatchesUpdatesBackticksLast Modified ByJavaScript Actions';tableBodyHTML="";var d,h=[],i={};for(var j in root.symbols)if(d=root.symbols[j],a.test(j)){var k,l,m;if(void 0===d.eden_definition)l="-",k="function"==typeof d.cache.value?"Function":"Observable",m=Eden.htmlEscape(Eden.edenCodeForValue(d.cache.value));else if(l=Eden.htmlEscape(d.eden_definition),0==l.indexOf("proc")){if(Eden.isitSystemAgent(j)&&!new RegExp("\\b"+j+"\\b").test(a.source))continue;k="Agent",m=""}else if(0==l.indexOf("func")){if(Eden.isitSystemFunction(j)&&!new RegExp("\\b"+j+"\\b").test(a.source))continue;k="Function",m=""}else k="Dependency",m=Eden.htmlEscape(Eden.edenCodeForValue(d.cache.value));h.push([d,j,k,l,m]),i[j]=!0}for(var n=0;n

          '+o[1]+'

          '+o[2]+'

          '+o[3]+'

          '+o[4]+'

          '+r+'

          '+u+'

          '+v+'

          '+w+'

          '+x+"

          ";/^((_view_.*)|mousePosition|mouseView)$/.test(o[1])?tableBodyHTML+=y:tableBodyHTML=y+tableBodyHTML}return""+c+tableBodyHTML+"
          "},e=function(a,b,c){var d=[];for(var e in a){var f=e.slice(1);d.push(g(f,b,c))}return d.join(", ")},f=function(a,b,c){for(var d=[],e=0;e"+a+"
          ":""+a+""};this.addSymbolToSearch=function(b,c){var d,e=document.getElementById(b+"-regexp");d="false"==a.getOptionValue("optSimpleWildcards")?e.value+"|^"+c+"$":e.value+" "+Language.ui.search.disjunction+" "+c,e.value=d,this.search(b)},this.jump=function(a){var b=location.href;location.href="#"+a,history.replaceState(null,null,b)},b()},EdenUI.plugins.SymbolLookUpTable.title="Symbol Look-Up Table",EdenUI.plugins.SymbolLookUpTable.description="Displays detailed information about symbols.",EdenUI.plugins.SymbolLookUpTable.originalAuthor="Joe Butler";var edenfunctions={};SymbolMeta=function(a){this.symbol=a,this.interestingness=0,this.significance=.5,this.index=0,this.isinteresting=!1,this.oldstr=""},SymbolMeta.DependencyComplexityRate=.4,SymbolMeta.DependencyChangeProbability=.01,SymbolMeta.SubscriberRate=.1,SymbolMeta.DecayRate=.9999,SymbolMeta.DependencyPercentage=.5,SymbolMeta.SubscriberPercentage=.5,SymbolMeta.SigDeleteRate=.1,SymbolMeta.SigInterestingRate=1.01,SymbolMeta.prototype.dependencyInterestingness=function(a){var b=0,c=0,d=.1;for(var e in this.symbol.dependencies){b++,d+=(1-d)*SymbolMeta.DependencyComplexityRate;var f=e.substr(1);void 0!==a.meta[f]&&a.meta[f].interestingness>=a.minInteresting()&&c++}return d-=b*SymbolMeta.DependencyChangeProbability,0!=b&&(d=.5*d+.5*(c/b)),d<0?0:d},SymbolMeta.prototype.subscriberInterestingness=function(a){var b=0,c=0,d=0;for(var e in this.symbol.subscribers){b++,d+=(1-d)*SymbolMeta.SubscriberRate;var f=e.substr(1);void 0!==a.meta[f]&&a.meta[f].interestingness>=a.minInteresting()&&c++}return d=1-d,0!=b&&(d=.5*d+.5*(c/b)),d},SymbolMeta.prototype.nameInterestingness=function(){var a=this.symbol.name.substr(1);return"_"==a[0]?.5:/\d/.test(a)?.9:1},SymbolMeta.prototype.frequencyInterestingness=function(){},SymbolMeta.prototype.update=function(a){var b=0;b=this.dependencyInterestingness(a)*this.subscriberInterestingness(a)*this.nameInterestingness()*this.significance,this.interestingness=b},EdenUI.plugins.ObservableMining=function(a,b){var c=this;this.meta={},this.interesting=[],this.limitInteresting=15,this.symresults=void 0,this.symbolsui=[];var d=function(a){var b='
          ';return b};this.createDialog=function(a,b){var e=(a.slice(0,-7),$("
          "));e.html(d(a)),c.symresults=e.find(".symbolframer-results")[0],$dialog=$('
          ').html(e).dialog({title:b,width:360,height:400,minHeight:200,minWidth:200,dialogClass:"unpadded-dialog"})},this.delay=100;var e=void 0,f=function(){if(void 0!==c.symresults){var a=$(c.symresults).parent();$(c.symresults).detach();for(var b=0;b=c.minInteresting())){c.interesting.length;if(c.interesting.length==c.limitInteresting){var g=c.interesting[c.interesting.length-1];g.isinteresting=!1,c.interesting.pop()}c.interesting.push(e),e.isinteresting=!0,e.significance*=SymbolMeta.SigInterestingRate,c.interesting.sort(function(a,b){return b.interestingness-a.interestingness})}}},a.eden.root.addGlobal(e),a.views.ObservableMining={dialog:this.createDialog,title:"Observable Mining",category:a.viewCategories.comprehension,menuPriority:1},$(document).tooltip(),b()},EdenUI.plugins.ObservableMining.prototype.minInteresting=function(){return this.interesting.length>0?this.interesting[this.interesting.length-1].interestingness:0},EdenUI.plugins.ObservableMining.prototype.maxInteresting=function(){return this.interesting.length>0?this.interesting[0].interestingness:0},EdenUI.plugins.ObservableMining.title="Observable Mining",EdenUI.plugins.ObservableMining.description="Automatically generate search for interesting observables",EdenUI.plugins.ObservableMining.Symbol=function(){this.symbol=void 0,this.name=void 0,this.meta=void 0,this.element=$('
          '),this.details=void 0,this.update=void 0,this.outofdate=!1,this.dodelete=!1,this.symbolChanged=void 0,this.editing=!1,this.update=this.updateObservable;var a=this;this.element.hover(function(){$(this).animate({backgroundColor:"#eaeaea"},100)},function(){$(this).animate({backgroundColor:"#fafafa"},100),1==a.editing&&(a.editing=!1,a.element.find("textarea").remove(),a.element.animate({height:"20px"},"fast"))}).click(function(){if(!a.editing){var b;b="function"==typeof a.symbol.value()&&void 0!==a.symbol.eden_definition?a.symbol.eden_definition:a.symbol.definition?a.symbol.eden_definition+";":a.name+" = "+Eden.edenCodeForValue(a.symbol.value())+";",a.element.animate({height:"60px"},{duration:200,complete:function(){var c=$('');c.val(b),c.appendTo(a.element),c.show("fast")}}),a.editing=!0}}).draggable({distance:40,axis:"x",scroll:!1,drag:function(b,c){c.position.left>150?a.dodelete=!0:a.dodelete=!1},revert:function(b,c){return!a.dodelete},stop:function(b,c){a.dodelete&&(a.meta.significance*=SymbolMeta.SigDeleteRate,a.symbolChanged(a.symbol,!1),a.element.hide("drop",{direction:"right"},"slow",function(){a.element.remove()}))}})},EdenUI.plugins.ObservableMining.Symbol.prototype.updateObservable=function(a,b){if(void 0!==this.symbol){0==b&&(b=1);var c,d=(this.meta.interestingness-a)*(1/(b-a)),e=Math.round(8+12*d),f=this.symbol.value(),g=_formatFramerVal(f);c=void 0!==this.symbol.definition?""+this.name+"":this.name;var h=""+c+" = "+g+"";if(void 0!==this.symbol.definition){var i=Eden.htmlEscape(this.symbol.eden_definition,!1,!0);i=Eden.htmlEscape("
          "+i+";
          "),h=""+h+""}var j=this.element.find(".observable");j.html(h),j.css({"font-size":e+"px"})}},EdenUI.plugins.ObservablePalette=function(a,b){function c(a){var b=a.value();return"function"!=typeof b||!/\breturn\s+([^\/;]|(\/[^\/*]))/.test(b.toString())}function d(a,b){var d=a.term,e=i[d];if(void 0===e){var f=new RegExp("^"+d);e=[];for(var g in root.symbols)f.test(g)&&c(root.symbols[g])&&e.push(g);i[d]=e}b(e)}function e(){var a=h;return h++,a}function f(b,c,d,g,h,i){function j(a){var b=a.target.value;if("hide"==b)return void h.remove(c,g,d);var e;"boolean"==b?e=!1:"number"==b?e=0:"string"==b&&(e=""),o.assign(e,Symbol.hciAgent,!0)}function k(a){pa.fadeOut(250,"linear",function(){a?(pa.html("true"),pa.css("color","green")):(pa.html("false"),pa.css("color","red")),pa.fadeIn(400,"swing",function(){y.html(a?"true":"false")})})}var l=128;g?(g.hasClass("ui-accordion")&&g.accordion("destroy"),g.html("")):(g=$('
          '),i&&g.data("editor","read-only"));var m,n=a.eden.root,o=n.lookup(c),p=o.value(),q=typeof p,r="string"==q,s=!i||r,t=o.eden_definition;if(!i&&void 0!==o.eden_definition){var u=t.match(/^\S+\s+is\s+(.*?);?$/);rhs=u[1],q="definition"}var v=$('

          '+c+"

          ");i&&g.addClass("observable-palette-dependency-value-box");var w=$('
          ');v.append(w),g.append(v);var x=Eden.prettyPrintValue("",p,l,!1,!1),y=$(""+x+"");w.append(y);var z=$("");i?z.append('"):(z.append(''),z.append(''),z.append(''),z.append('')),z.append(''),z[0].value=q,z.on("change",j),w.on("click",function(a){a.stopPropagation()}),y.on("click",function(a){y.detach(),w.append(z),z.focus()}),z.on("blur",function(a){z.detach(),w.append(y)});var A=$("
          ");if("definition"==q){var B=$('
          ');B.append(c+" is "),rhsSpan=$(''),rhsSpan.append(Eden.htmlEscape(rhs)),B.append(rhsSpan),B.append(";"),B.on("click",function(a){rhsSpan.focus(),B.addClass("focussed")}),rhsSpan.on("blur",function(a){B.removeClass("focussed")}),A.append(B);var C=$('
          ');A.append(C);var D=$('Expand');D.click(function(){H.find(".observable-palette-obs-box.ui-accordion").accordion("option","active",0)});var E=$('Collapse');E.click(function(){H.find(".observable-palette-obs-box.ui-accordion").accordion("option","active",!1)});var F=$('Hide');F.click(function(){var a=H.find(".observable-palette-obs-box");a.removeClass("observable-palette-visible"),a.slideUp()});var G=$('Show');G.click(function(){var a=H.find(".observable-palette-obs-box");a.addClass("observable-palette-visible"),a.slideDown()}),C.append(D),C.append(E),C.append(F),C.append(G);var H=$('
          ');H.sortable({connectWith:".observable-palette-column",forcePlaceholderSize:!0,handle:"h3",items:">.observable-palette-obs-box",placeholder:"observable-palette-drag-placeholder",tolerance:"pointer",receive:function(a,b){var d=b.item,e=d.data("observable");(!o.isDependentOn("/"+e)||e==c&&"read-only"!=d.data("editor"))&&b.sender.sortable("cancel"),2==H.children(".observable-palette-visible").length&&C.slideDown(),h.removeDuplicates(a.target,d)},remove:function(a,b){H.children(".observable-palette-visible").length<2&&C.slideUp()}});var I,J=0;for(var K in o.dependencies){var L=o.dependencies[K];K=K.slice(1),void 0===L.eden_definition&&(I=f(b,K,e(),void 0,h,!1),h.register(K,I),H.append(I),J++)}if(J<2&&C.hide(),m=function(a,e){var i=a.eden_definition;void 0===i?f(b,c,d,g,h,!1):y.html(Eden.prettyPrintValue("",e,l,!1,!1))},A.append(H),r){var M=f(b,c,e(),void 0,h,!0);H.append(M)}}else if("number"==q){var N,O,P;if(P=1==p||p==-1||p!=Math.floor(p)?5e-4:1,0==p)N=0,O=10;else if(p>=-1&&p<=1)N=p>0?0:-1,O=1;else if(p<0){N=2*p;var Q=Number((-p%P).toPrecision(14)); +0!=Q&&Q!=P&&(N=N+Q-P),O=N+2*(p-N)}else N=0,O=2*Math.ceil((p/P).toPrecision(16))*P;var R=$(''),S=R[0];R.on("input",function(a){o.assign(parseFloat(S.value),Symbol.hciAgent,!0)});var T=$('
          '),U=$("");T.append(U);var V=$('');V.append(R),U.append(V);var W=$('');T.append(W);var X=$(''),Y=$(''),Z=Y[0];X.append(Y),W.append(X),Y.on("input",function(a){var b=a.target.value;if(""!=b){var c=parseFloat(b);S.min=b;var d=o.value();c>=0&&d0?c+Math.ceil((c/e).toPrecision(16))*e:Math.ceil((c/2/e).toPrecision(16))*e,f');W.append(ca);var da=$('
          ');ca.append(da);var ea=$('');da.append(ea);var fa=$(''),ga=fa[0];ea.append(fa),fa.on("input",function(a){var b=a.target.value;""!=b&&(S.value=b,o.assign(parseFloat(b),Symbol.hciAgent,!0))}),fa.on("focus",function(a){ba=!0,aa=a.target.value}),fa.on("blur",function(a){var b=a.target.value;if(""==b)o.assign(parseFloat(aa),Symbol.hciAgent,!0);else{var c=o.value(),d=parseFloat(S.min);c'),ia=$(''),ja=ia[0];ha.append(ia),W.append(ha),ia.on("input",function(a){S.max=a.target.value});var ka=$('');da.append(ka);var la=$(''),ma=la[0];ma.acceptedValue=P,ka.append(la),la.on("input",function(a){var b=parseFloat(ma.value);if(b>0){var c,d=Math.floor(b);if(b==d){var e=String(b).match(/(0*)$/);c=Math.pow(10,e[1].length)}else c=Math.pow(10,-((b-d).toPrecision(15).replace(/0*$/,"").length-2));b==c&&b0?(j=Math.ceil(e/2/p)*p-p,m=Number((e%p).toPrecision(14)),0!=m&&m!=p&&(j+=m)):(j=2*e,m=Number((-e%p).toPrecision(14)),0!=m&&m!=p&&(j=j+m-p)),S.min=j,Z.value=j,k=j+Math.round((o-j)/p)*p,S.max=k,ja.value=k):e>o&&(k=n+2*Math.ceil(((e-n)/p).toPrecision(16))*p,S.max=k,ja.value=k),S.value=e,ga.value=e}},A.append(T)}else if("boolean"==q){var na=$(''),oa=na[0],pa=$('');na.on("change",function(a){var b=oa.checked;o.assign(b,o.hciAgent,!0)}),m=function(a,e){e!==!0&&e!==!1||void 0!==a.eden_definition?f(b,c,d,g,h,i):(oa.checked=e,k(e))},k(p);var qa=$('');qa.append(na),qa.append(pa),A.append(qa)}else if("string"==q){var ra=$('"),sa=ra[0];ra.on("input",function(a){var b=sa.value;o.assign(b,Symbol.hciAgent,!0),sa.style.height="",sa.style.height=String(sa.scrollHeight+4)+"px"}),m=function(a,e){"string"!=typeof e||void 0!==a.eden_definition?f(b,c,d,g,h,i):(sa.value=e,sa.rows=e.split("\n").length,y.html(Eden.prettyPrintValue("",e,l,!1,!1)))},A.append($('
          ')),A.append(ra),A.append($('
          '))}else if("undefined"==q){if(A.append($('

          '+c+" is currently undefined.

          ")),!i){var ta=z.clone();ta[0].value="undefined",ta.on("change",j);var ua=$("");ua.append(ta);var va=$("
          ");va.append(ua),A.append(va)}m=function(a,e){void 0===e&&void 0===a.eden_definition||f(b,c,d,g,h,i)}}else m=function(a,e){void 0===e&&void 0===a.eden_definition||f(b,c,d,g,h,i)};return o.addJSObserver(b+"/"+c+"/"+d,m),s?(i&&A.find("input, textarea").attr("readonly","readonly"),g.append(A),g.accordion({active:"undefined"!=q&&void 0,collapsible:!0,heightStyle:"content"})):v.addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all observable-palette-static-header"),g.removeFromDialog=function(){h.remove(c,g,d)},g}function g(a,b){a.target.style.minWidth=b.size.width+"px"}var h=0,i={};root.addGlobal(function(a,b,d){if(d&&c(b)){var e=b.name.slice(1);for(var f in i)new RegExp("^"+f).test(e)&&i[f].push(e)}}),this.createDialog=function(b,c){function h(a,b){for(var c=b.data("observable"),d=b[0],e=p[c],f=0;f'),p={},q=$(''),r=q[0];q.on("keyup",function(a){13==a.which&&(j(r.value,0,!1),r.value="")}),q.autocomplete({minLength:2,source:d});var s=$('');s.click(function(){j(r.value,0,!1),r.value=""});var t=$('');t.on("click",function(a){l(r.value),r.value=""});var u=$(""),v=$(''),w=v[0];u.append(v),u.append(" Advanced");var x=root.lookup("_view_"+m+"_advanced"),y=x.value();void 0===y?(x.assign(!1,n),o.addClass("observable-palette-no-advanced")):y||o.addClass("observable-palette-no-advanced"),x.addJSObserver("repaintView",function(a,b){o.toggleClass("observable-palette-no-advanced",!b),w.checked=b}),v.on("change",function(a){x.assign(a.target.checked,n)});var z=$('
          ');z.append(q),z.append(s),z.append(t),z.append(u);var A=[],B=7,C=root.lookup("_view_"+m+"_observables"),D=C.value();Array.isArray(D)&&(D.length>0&&!Array.isArray(D[0])&&(D=[D]),D.length>B&&(B=D.length));for(var E=0;E');F.sortable({connectWith:".observable-palette-column, .observable-palette-dependencies",forcePlaceholderSize:!0,handle:"h3",items:">.observable-palette-obs-box",placeholder:"observable-palette-drag-placeholder",scroll:!1,tolerance:"pointer",receive:function(a,b){var c=a.target,d=b.item;h(c,d)}}),E')),e=($("
          "),$('
          '),$('
          '),$('
          '));d.append(e);var f=$('');d.append(f);var g={};e.on("click",".scriptgen-importex",function(a){var b=a.currentTarget.getAttribute("data-agent");g[b]?g[b]=!1:g[b]=!0,h()});var h=function(){e.html("");for(var a=c.generateScriptLines(g),b=0;b '+f[1]+"";if(f.length>2)for(var i=2;i'+(g[d]?"":"")+""+(g[d]?'## '+a.imports[b]+"":h)+"");e.append(j)}e.append($('
          '));var k=$("
          ");e.append(k);var l=a.definitions.join("\n")+"\n## When agents\n\n"+a.agents,m=new Eden.AST(l,(void 0),{name:"*JavaScript"}),n=new EdenUI.Highlight(k.get(0));n.highlight(m,-1,-1)};f.click(function(){h()}),h(),$('
          ').html(d).dialog({appendTo:"#jseden-views",title:b,width:790,height:700,minHeight:120,minWidth:230,dialogClass:"scriptgen-dialog"})};this.generateScriptLines=function(a){var b={},c=Eden.Generator.importsScript().split("\n");b.imports=c;var d=Eden.Generator.symbolScript(a).split("\n");b.definitions=d;var e=Eden.Agent.getActiveAgents(a,!1);return b.agents=e,b},this.baseConstrualSymbols={},this.changeListener=function(a,b){var d=a.last_modified_by;if(!b&&"include"!=d){var e=a.name.slice(1);void 0!==a.eden_definition&&void 0!==a.definition?c.baseConstrualSymbols[e]={eden_definition:a.eden_definition,last_modified_by:d}:c.baseConstrualSymbols[e]={cached_value:a.cached_value,last_modified_by:d}}},a.eden.listenTo("executeError",EdenUI.plugins.ScriptGenerator,function(a,b){root.removeGlobal(c.changeListener)}),this.baseConstrualURL="",a.views.ScriptGenerator={dialog:this.createDialog,title:"Script Generator",category:a.viewCategories.history},b()},EdenUI.plugins.ScriptGenerator.title="Script Generator",EdenUI.plugins.ScriptGenerator.description="Generates a definitional script that can be used to recreate the current state of the environment at a later time.",EdenUI.plugins.ScriptGenerator.originalAuthor="Joe Butler",EdenUI.plugins.ScriptGenerator.loadBaseConstrual=function(a){"ScriptGenerator"in edenUI.plugins&&root.addGlobal(edenUI.plugins.ScriptGenerator.changeListener),eden.include(a,"",{name:Symbol.getInputAgentName()},function(){"ScriptGenerator"in edenUI.plugins&&(root.removeGlobal(edenUI.plugins.ScriptGenerator.changeListener),edenUI.plugins.ScriptGenerator.baseConstrualURL=a)})},function(){"use strict";var a,b=this;a="undefined"!=typeof exports?exports:b.Springy={};var c=a.Graph=function(){this.nodeSet={},this.nodes=[],this.edges=[],this.adjacency={},this.nextNodeId=0,this.nextEdgeId=0,this.eventListeners=[]},d=a.Node=function(a,b){this.id=a,this.data=void 0!==b?b:{}},e=a.Edge=function(a,b,c,d){this.id=a,this.source=b,this.target=c,this.data=void 0!==d?d:{}};c.prototype.addNode=function(a){return a.id in this.nodeSet||this.nodes.push(a),this.nodeSet[a.id]=a,this.notify(),a},c.prototype.addNodes=function(){for(var a=0;a=0;b--)this.nodes[b].id===a.id&&this.nodes.splice(b,1);this.detachNode(a)},c.prototype.detachNode=function(a){var b=this.edges.slice();b.forEach(function(b){try{b.source.id!==a.id&&b.target.id!==a.id||this.removeEdge(b)}catch(c){}},this),this.notify()},c.prototype.removeEdge=function(a){for(var b=this.edges.length-1;b>=0;b--)this.edges[b].id===a.id&&this.edges.splice(b,1);for(var c in this.adjacency){for(var d in this.adjacency[c]){for(var e=this.adjacency[c][d],f=e.length-1;f>=0;f--)this.adjacency[c][d][f].id===a.id&&this.adjacency[c][d].splice(f,1);0==this.adjacency[c][d].length&&delete this.adjacency[c][d]}j(this.adjacency[c])&&delete this.adjacency[c]}this.notify()},c.prototype.merge=function(a){var b=[];a.nodes.forEach(function(a){b.push(this.addNode(new d(a.id,a.data)))},this),a.edges.forEach(function(a){var c=b[a.from],d=b[a.to],f=a.directed?f=a.type+"-"+c.id+"-"+d.id:c.idb.x&&(b.x=d.p.x),d.p.y>b.y&&(b.y=d.p.y)});var c=b.subtract(a).multiply(.07);return{bottomleft:a.subtract(c),topright:b.add(c)}};var h=a.Vector=function(a,b){this.x=a,this.y=b};h.random=function(){return new h(10*(Math.random()-.5),10*(Math.random()-.5))},h.prototype.add=function(a){return new h(this.x+a.x,this.y+a.y)},h.prototype.subtract=function(a){return new h(this.x-a.x,this.y-a.y)},h.prototype.multiply=function(a){return new h(this.x*a,this.y*a)},h.prototype.divide=function(a){return new h(this.x/a||0,this.y/a||0)},h.prototype.magnitude=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},h.prototype.normal=function(){return new h((-this.y),this.x)},h.prototype.normalise=function(){return this.divide(this.magnitude())},f.ForceDirected.Point=function(a,b){this.p=a,this.m=b,this.v=new h(0,0),this.a=new h(0,0)},f.ForceDirected.Point.prototype.applyForce=function(a){this.a=this.a.add(a.divide(this.m))},f.ForceDirected.Spring=function(a,b,c,d){this.point1=a,this.point2=b,this.length=c,this.k=d};var i=a.Renderer=function(a,b,c,d){this.layout=a,this.clear=b,this.drawEdge=c,this.drawNode=d,this.layout.graph.addGraphListener(this)};i.prototype.graphChanged=function(a){this.start()},i.prototype.start=function(){var a=this;this.layout.start(function(){a.clear(),a.layout.eachEdge(function(b,c){a.drawEdge(b,c.point1.p,c.point2.p)}),a.layout.eachNode(function(b,c){a.drawNode(b,c.p)})})},i.prototype.stop=function(){this.layout.stop()},Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("[object Function]"!={}.toString.call(a))throw new TypeError(a+" is not a function");for(b&&(c=b),d=0;d1||g<0||g>1)&&new Springy.Vector(a.x+f*(b.x-a.x),a.y+f*(b.y-a.y))}function c(a,c,d,e,f){var g,h={x:d.x,y:d.y},i={x:d.x+e,y:d.y},j={x:d.x,y:d.y+f},k={x:d.x+e,y:d.y+f};return(g=b(a,c,h,i))?g:(g=b(a,c,i,k))?g:(g=b(a,c,k,j))?g:!!(g=b(a,c,j,h))&&g}var d=this.graph=a.graph||new Springy.Graph,e=a.stiffness||100,f=a.repulsion||5e3,g=a.damping||.5,h=a.nodeSelected||null,i=this[0],j=i.getContext("2d"),k=this.layout=new Springy.Layout.ForceDirected(d,e,f,g),l=k.getBoundingBox(),m={bottomleft:new Springy.Vector((-2),(-2)),topright:new Springy.Vector(2,2)};Springy.requestAnimationFrame(function a(){m=k.getBoundingBox(),l={bottomleft:l.bottomleft.add(m.bottomleft.subtract(l.bottomleft).divide(10)),topright:l.topright.add(m.topright.subtract(l.topright).divide(10))},Springy.requestAnimationFrame(a)});var n=function(a){var b=l.topright.subtract(l.bottomleft),c=a.subtract(l.bottomleft).divide(b.x).x*i.width,d=a.subtract(l.bottomleft).divide(b.y).y*i.height;return new Springy.Vector(c,d)},o=function(a){var b=l.topright.subtract(l.bottomleft),c=a.x/i.width*b.x+l.bottomleft.x,d=a.y/i.height*b.y+l.bottomleft.y;return new Springy.Vector(c,d)},p=null,q=null,r=null;jQuery(i).mousedown(function(a){var b=jQuery(this).offset(),c=o({x:a.pageX-b.left,y:a.pageY-b.top});p=q=r=k.nearest(c),null!==p.node&&(r.point.m=1e4,h&&h(p.node)),s.start()}),jQuery(i).dblclick(function(a){var b=jQuery(this).offset(),c=o({x:a.pageX-b.left,y:a.pageY-b.top});p=k.nearest(c),node=p.node,node&&node.data&&node.data.ondoubleclick&&node.data.ondoubleclick()}),jQuery(i).mousemove(function(a){var b=jQuery(this).offset(),c=o({x:a.pageX-b.left,y:a.pageY-b.top});q=k.nearest(c),null!==r&&null!==r.node&&(r.point.p.x=c.x,r.point.p.y=c.y),s.start()}),jQuery(window).bind("mouseup",function(a){r=null}),Springy.Node.prototype.getWidth=function(){var a=void 0!==this.data.label?this.data.label:this.id;if(this._width&&this._width[a])return this._width[a];j.save(),j.font="16px Verdana, sans-serif";var b=j.measureText(a).width+10;return j.restore(),this._width||(this._width={}),this._width[a]=b,b},Springy.Node.prototype.getHeight=function(){return 20};var s=this.renderer=new Springy.Renderer(k,function(){var a=i.parentNode;null!==a&&(i.height=a.clientHeight,i.width=a.clientWidth),j.clearRect(0,0,i.width,i.height)},function(a,b,e){for(var f=n(b).x,g=n(b).y,h=n(e).x,i=n(e).y,k=new Springy.Vector(h-f,i-g),l=k.normal().normalise(),m=d.getEdges(a.source,a.target),o=d.getEdges(a.target,a.source),p=m.length+o.length,q=0,r=0;r'),h=$("").springy({graph:f,nodeSelected:function(a){}});g.append(h);var i=$('
          ');g.append(i);var j=$(''),k=j.get(0),l=$(''),m=l.get(0);i.append(j),i.append($("").append(l)),j.on("input",e),l.on("change",e),g.on("mouseenter",e),g.dialog({appendTo:"#jseden-views",title:d,width:600,height:450,minHeight:120,minWidth:230,dialogClass:"dependency-map-dialog"})},this.updateGraph=function(a,b){a.re=b,a.newNodes=[],a.newEdges=[];for(var c in root.symbols){var d=root.symbols[c],e=d.name;if(b.test(e)){a.newNodes.indexOf(e)==-1&&a.newNodes.push(e);var f=d.dependencies;for(var g in f){var h=f[g].name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h),a.newEdges.push([h,e,!1])}f=d.dynamicDependencies;for(var g in f){var h=f[g].name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h),a.newEdges.push([h,e,!0])}f=d.observees;for(var g in f){var h=f[g].name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h),a.newEdges.push([h,e,!1])}var i=d.subscribers;for(var g in i){var j=i[g],h=j.name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h);var k=d.name in j.dynamicDependencies;a.newEdges.push([e,h,k])}i=d.observers;for(var g in i){var h=i[g].name;a.newNodes.indexOf(h)==-1&&a.newNodes.push(h),a.newEdges.push([e,h,!1])}}}if(!arrayCompare(a.previousNodes,a.newNodes)||!arrayCompare(a.previousEdges,a.newEdges)){a.previousNodes=a.newNodes,a.previousEdges=a.newEdges,a.filterEdges(function(a){return!1}),a.filterNodes(function(a){return!1}),a.nodeObjectsStore={};for(var c in a.previousNodes){var l=a.previousNodes[c];a.nodeObjectsStore[l]=a.newNode({label:l},{color:"#6A4A3C"})}for(var g in a.previousEdges){var m=a.previousEdges[g][0],n=a.previousEdges[g][1],o={};a.previousEdges[g][2]&&(o.dashes=[10,10]),a.newEdge(a.nodeObjectsStore[m],a.nodeObjectsStore[n],o)}}},a.views.DependencyMap={dialog:this.createDialog,title:"Dependency Map",category:a.viewCategories.comprehension,menuPriority:2},b()},EdenUI.plugins.DependencyMap.title="Dependency Map",EdenUI.plugins.DependencyMap.description="Displays a diagram showing the relationships between observables.",EdenUI.plugins.DependencyMap.author="Joe Butler",EdenUI.plugins.StateTimeLine=function(a,b){var c=this;this.createDialog=function(b,e){c.ignoreRE=new RegExp("((_view.*)|(_View.*)|(_status)|(mouse.*)|(picture))"),code_entry=$('
          ').append($('')).append($('').click(function(){c.ST.states.push(d("partial"));var e=document.getElementById(b+"-regex").value;""==e&&(e="State "+c.ST.nextBlankState),$("#"+b+"-content-states").append("
          "+e+": Restore "+(new Date).toLocaleTimeString()+" Delete
          "),document.getElementById(b+"-regex").value="",a.plugins.StateTimeLine.ST.nextBlankState++})).append($('
          ')),$dialog=$('
          ').html(code_entry).dialog({title:e,width:300,height:450,minHeight:120,minWidth:230})},c.ST={},c.ST.states=[],c.ST.nextBlankState=0,this.deleteState=function(a){$(document.getElementById("stdiv"+a)).remove()},this.changeState=function(b){for(var c in root.symbols)Eden.isitSystemSymbol(root.symbols[c].name.substring(1,root.symbols[c].name.length))||a.plugins.StateTimeLine.ignoreRE.test(root.symbols[c].name.substring(1,root.symbols[c].name.length))||delete root.symbols[c];a.plugins.ScriptInput.submitEdenCode(a.plugins.StateTimeLine.ST.states[b])};var d=function(b){var c=[],d=[],e=[],f=[],g="autocalc = 1;",h="autocalc = 0;",i=root.lookup("picture").eden_definition;void 0==i?i="picture is [];":i+=";";for(var j in root.symbols){var k="@",l="",m=5,n=root.symbols[j],o=n.eden_definition;if(void 0==o&&(o=k),0==o.indexOf("proc")){if(l="(Action)",m=2,"partial"==b&&Eden.isitSystemAgent(j))continue}else if(0==o.indexOf("func")){if(l="(Function)",m=1,"partial"==b&&Eden.isitSystemFunction(j))continue}else if(l="(Observable)",m=0,"partial"==b&&Eden.isitSystemObservable(j))continue;var p=Eden.edenCodeForValue(n.cached_value);if(!a.plugins.StateTimeLine.ignoreRE.test(j))if(1==m)f.push(o);else if(0==m){if(p==k&&o==k)continue;o==k?d.push(j+" = "+p+";"):c.push(o+";")}else 2==m?e.push(o):console.log("oh dear error")}var q=[];q.push(h);for(var r=0;r

          ';return $dialog=$('
          ').html(e).dialog({title:c,width:300,height:450,minHeight:120,minWidth:230}),$("#connectBtn").click(function(){function b(b){var c=a.eden.root,d=c.lookup("definitionOf").definition(c)(b);e.send(d)}if(window.WebSocket=window.WebSocket||window.MozWebSocket,!window.WebSocket)return void console.log("WebSockets not supported");var c="ws://"+$("#sl-ipaddr").val()+":"+$("#sl-port").val()+"/",e=new WebSocket(c);eden.listenTo("executeBegin",this,function(a,b){"net"!=a&&e.send(b)}),eden.listenTo("beforeAssign",this,function(a,b,c){"net"!=c&&e.send(a.name.slice(1)+"="+Eden.edenCodeForValue(b)+";")}),$("#sl-status").html("

          Connected to: "+c+"

          "), e.onerror=function(a){$("#sl-status").html("

          Error connecting to server - please verify server is running at "+c+". For usage instructions please read the comments in the state-listener-server.js file.

          "),d.confirmClose=!1},e.onmessage=function(a){$("#sl-status").html("

          Received: "+Eden.htmlEscape(a.data)+"

          "),eden.execute(a.data,"net","",{name:"/execute"},noop)},e.onopen=function(){d.confirmClose=!0,randomSeedSym=a.eden.root.lookup("randomSeed"),randomSeed=randomSeedSym.value(),void 0===randomSeed?randomSeedSym.assign((new Date).getTime(),eden.root.scope,void 0,!0):b("randomSeed"),b("randomGenerator")}}),d},a.views.StateListener={dialog:this.createDialog,title:"State Listener",category:a.viewCategories.extension},a.eden.include("plugins/state-listener/state-listener.js-e",b)},EdenUI.plugins.StateListener.title="State Listener",EdenUI.plugins.StateListener.description="Provides the ability to synchronize observables over the internet.",EdenUI.plugins.StateListener.author="Jonny Foss",EdenUI.plugins.NetworkRemote=function(a,b){function c(){h=!1,$("#connectBtn").attr("value","Connect"),$("#nr-ipaddr").removeAttr("disabled"),$("#nr-port").removeAttr("disabled"),$("#nr-key").removeAttr("disabled")}function d(){eden.root.lookup("network_address").assign($("#nr-ipaddr").val(),eden.root.scope),eden.root.lookup("network_port").assign($("#nr-port").val(),eden.root.scope),eden.root.lookup("network_key").assign($("#nr-key").val(),eden.root.scope),f.connect()}var e,f=this,g=!1,h=!1;Eden.Agent.importAgent("lib/dynamic","default",void 0,function(){}),f.connect=function(){function b(b){var c=a.eden.root,d=c.lookup("definitionOf").definition(c)(b);j.send(JSON.stringify({code:d}))}var c=eden.root.lookup("network_address").value(),d=eden.root.lookup("network_port").value(),g=eden.root.lookup("network_key").value();if(window.WebSocket=window.WebSocket||window.MozWebSocket,!window.WebSocket)return void console.log("WebSockets not supported");var i="ws://"+c+":"+d+"/",j=new WebSocket(i);Eden.Agent.listenTo("executeline",this,function(a,b){if(a){var c=JSON.stringify({action:"executeline",name:a.name,lineno:b});j.send(c)}}),Eden.Agent.listenTo("patch",this,function(a,b,c){if(a){var d=JSON.stringify({action:"patch",name:a.name,patch:b,lineno:c});j.send(d)}}),Eden.Agent.listenTo("owned",this,function(a,b){"net"!=b&&j.send(JSON.stringify({action:"ownership",name:a.name,owned:a.owned}))}),eden.listenTo("beforeAssign",this,function(a,b,c){"net"!=c&&(console.log("ASSIGN: "+a.name+" = "+Eden.edenCodeForValue(b)),j.send(JSON.stringify({action:"assign",symbol:a.name.slice(1),value:b})))}),$("#nr-status").html("

          Connected to: "+i+"

          "),j.onopen=function(c){j.send(g),randomSeedSym=a.eden.root.lookup("randomSeed"),randomSeed=randomSeedSym.value(),void 0===randomSeed?randomSeedSym.assign((new Date).getTime(),eden.root.scope,void 0,!0):b("randomSeed"),b("randomGenerator"),h=!0;for(var d in Eden.Agent.agents)Eden.Agent.agents[d].owned&&j.send(JSON.stringify({action:"ownership",name:d,owned:!0}));eden.root.lookup("network_connected").assign(!0,eden.root.scope)},j.onerror=function(a){h=!1,eden.root.lookup("network_connected").assign(!1,eden.root.scope),eden.root.lookup("network_error").assign(a,eden.root.scope)},j.onclose=function(){eden.root.lookup("network_connected").assign(!1,eden.root.scope)},f.sendControl=function(a,b){console.log("Send Control: "+a+"= "+b),console.log(b),j.send(JSON.stringify({action:"control",key:a,value:b}))},f.sendAssign=function(a){"net"!=a.last_modified_by&&j.send(JSON.stringify({action:"assign",symbol:a.name.slice(1),value:a.value()}))},j.onmessage=function(a){e=JSON.parse(a.data);for(var b=0;b

          ';return $dialog=$('
          ').html(f).dialog({title:b,width:300,height:450,minHeight:120,minWidth:230}),$("#connectBtn").click(function(){h?c():d()}),e},this.playCode=function(a){if(void 0===e[a])return void $("#nr-status").html("

          Replay finished

          ");var b=e[a].time/$("#nr-speedrange").val();b>1e3?($("#nr-status").html("

          Next line in "+b+" milliseconds

          "),g=!0):g&&$("#nr-status").html("

          Replaying...

          "),setTimeout(function(){eden.execute(e[a].code,"net","",{name:"/execute"},noop),f.playCode(a+1)},b)},a.views.NetworkRemote={dialog:this.createDialog,title:"Network Remote",category:a.viewCategories.extension},a.eden.include("plugins/network-remote/network-remote.js-e",b),eden.root.lookup("plugins_network_loaded").assign(!0,eden.root.scope)},EdenUI.plugins.NetworkRemote.title="Network Remote",EdenUI.plugins.NetworkRemote.description="Method of syncronizing observables via TCP, and playing back scripts",EdenUI.plugins.NetworkRemote.author="Jonny Foss",EdenUI.plugins.WindowLayoutTool=function(a,b){var c="";$.getScript("plugins/view-layout/gridster/jquery.gridster.min.js");var d=$("");$("head").append(d);var d=$("");$("head").append(d),this.name="window_name",this.createDialog=function(b,d){""==c&&(c=b);var e=[];viewlayoutstr="View Layout";var f=5*a.gridSizeY,g=3*a.gridSizeX,h=[],i=root.lookup("_views_list").value(),j=this.name;i.forEach(function(b){if(b!=j){var c=root.lookup("_view_"+b+"_x").value(),d=root.lookup("_view_"+b+"_y").value();c="undefined"!=typeof c?c:0,d="undefined"!=typeof d?d:0,h=[b,c,d,root.lookup("_view_"+b+"_width").value()+a.scrollBarSize,root.lookup("_view_"+b+"_height").value()+a.titleBarHeight,root.lookup("_view_"+b+"_title").value()],console.log(h),e.push(h)}});var k="";e.forEach(function(a,b){k+='
        1. '+a[5]+" ["+a[0]+"]
        2. "});var l='Update
            '+k+"
          ";$dialog=$('
          ').html(l).dialog({title:d,width:$(window).width()/2,height:$(window).height()/2,minHeight:120,minWidth:230}),gridster=$(".gridster ul").gridster({widget_base_dimensions:[g,f],widget_margins:[0,0],min_cols:Math.round($(window).width()/g),max_cols:Math.round($(window).width()/g),helper:"clone",resize:{enabled:!0},serialize_params:function(a,b){return{col:b.col,row:b.row,size_x:b.size_x,size_y:b.size_y,name:b.name,name:$(b.el.context).attr("data-name")}}}).data("gridster"),$(".vl-update").click(function(){var b=gridster.serialize(),c=1,d=1;b.forEach(function(a,b){a.col "+this.actions},d.prototype.toString=function(){return this.name+"("+this.parameters.join(",")+")\nDefinitions:\n"+this.definitions+"\nActions:\n"+this.actionsArr};var g=function(a,b){for(var d=new Array,e=0;e");if(2==g.length){var h="this_g"+d.length;d.push(new c(h,g[0],g[1]))}}return d},h=function(a){var b,c=new Array;a.split("(").length<2?b=a:(c=a.split("(")[1].split(")")[0].split(","),b=a.split("(")[0]);var d=document.getElementById("adm-definitions"),e=[];d.value.length>0&&(e=d.value.split("\n"));var d=document.getElementById("adm-actions"),f=d.value.split("\n"),h=g(b,f);return F(b,c,e,h),0},i=function(){for(var a=document.getElementById("adm-name"),b=a.value.split("(")[0],c=!0,d=0;d=f.templates.length&&(a=-1),a==-1)document.getElementById("adm-name").value="",document.getElementById("adm-definitions").value="",document.getElementById("adm-actions").value="";else{var b=f.templates[a];document.getElementById("adm-name").value=b.name,document.getElementById("adm-definitions").value=b.definitions.join("\n"),document.getElementById("adm-actions").value=b.actionsArr.join("\n")}f.currIndex=a},k=function(a){a>-1&&(alert("Deleting template "+f.templates[a].name),f.templates.splice(a),f.currIndex=a-1,j(f.currIndex))},l=function(a){return'
          \t\t\t
          Name:
          \t\t\t
          \t\t\t
          Definitions:
          \t\t\t
          \t\t\t
          Actions:
          \t\t\t
          \t\t
          \t\t
          \t\t\t
          \t\t
          '};this.createTemplateCreator=function(a,b){var c=$("
          ");c.html(l(a)),$dialog=$('
          ').html(c).dialog({title:b,width:360,height:400,minHeight:200,minWidth:360,buttons:[{id:"btn-add",text:"Add Template",click:function(){i()}},{id:"btn-delete",text:"Delete Template",click:function(){k(f.currIndex)}},{text:"Previous",click:function(){j(f.currIndex-1)}},{text:"Next",click:function(){j(f.currIndex+1)}}]}),input_dialog=$dialog,$("#btn-submit").css("margin-right","30px")};var m=function(a,b){var c=new Array;for(x in b){var d=b[x];c.push(d.replace(/this/g,a))}return c},n=function(a,b){var d=new Array;for(x in b){var e=b[x],f=e.guard.replace(/this/g,a),g=e.actions.replace(/this/g,a),h=e.edenVar.replace(/this/g,a);d.push(new c(h,f,g))}return d},o=function(a,b){a.value="";for(x in b)b[x].value=""},p=function(a){var b;for(x in f.templates)if(f.templates[x].name==a){b=f.templates[x];break}return b},q=function(){for(var a=document.getElementById("template-menu"),b=a.options[a.selectedIndex].value,c=p(b),d=document.getElementById("entity-name"),e=d.value,g=!0,h=0;h");c=$('
          \t\t\t\t\t
          Templates:
          \t\t\t\t\t
          \t\t\t\t\t\t\t\t\t\t\t
          \t\t\t\t\t
          Entity name:
          \t\t\t\t\t
          \t\t\t\t\t\t\t\t\t\t\t
          \t\t\t\t\t
          Parameters:
          \t\t\t\t\t
          \t\t\t\t
          '),$dialog=$('
          ').html(c).dialog({title:b,width:360,height:400,minHeight:200,minWidth:360,buttons:[{id:"btn-instantiate",text:"Instantiate",click:function(){q()}}]}),f.templateList=new EdenUI.plugins.ADM.TemplateList;for(x in f.templates){var d=f.templates[x];f.templateList.addTemplate(d.name,d.parameters)}};var s=function(a){var b,c;for(x in f.entities)if(f.entities[x].name==a){b=f.entities[x],c=x;break}if(null==b)return void alert(a+" doesn't exist to delete.");f.entities.splice(c,1);for(x in f.actionLists)if(f.actionLists[x].entityName==a){c=x,f.actionLists[x].remove();break}null!=f.actionLists&&f.actionLists.splice(c,1),null!=f.entityList&&f.entityList.removeEntity(a)},t=function(a,b,c){var d=p(a);if(null==d)return alert("no template with name "+a),-1;for(x in f.entities)if(f.entities[x].name==c)return alert("Please enter a unique entity name"),-1;if(""==b)var e=[];else if(b.indexOf(",")==-1)var e=[b];else var e=b.split(",");if(e.length!=d.parameters.length)return alert("not enough parameters to instantiate "+d),-1;for(x in e){var g=D(d.parameters[x]),h=D(e[x]);eden.executeEden(c+"_"+g+" is "+h+";")}var i=m(c,d.definitions),j=r(c,i);return j!=-1&&u(c,i,d.actionsArr),j},u=function(a,b,c){var d=n(a,c),g=new e(a,b,d);f.entities.push(g);for(x in d){var h=d[x],i=h.edenVar+" is "+h.guard+";";eden.executeEden(i)}if(null!=f.actionLists){var j=new EdenUI.plugins.ADM.ActionsList(a);f.actionLists.push(j),w(g,j)}null!=f.entityList&&f.entityList.addEntity(a,b,d)},v=function(){for(x in f.selectedActions){var b=f.selectedActions[x];if(b=D(b),945==b.charCodeAt(0))if("r"==b[2]){var c=b.split("(")[1];c=c.substring(0,c.length-1),s(c)}else if("i"==b[2]){var d=b.split("(")[1],e=b.split("(")[2].split(")")[0],c=b.split("as")[1],g=t(d,e,c);if(g==-1)break}else alert("Action on another entity must one of α_remove(entity_name), α_r, α_instantiate(template(param_value) as entity_name) or α_i");else eden.executeEden(b+";")}f.selectedActions=new Array,a.plugins.ADM.refreshHumanPerspective()};this.actionPush=function(a){f.selectedActions.push(a)},this.actionRemove=function(a){var b=new Array;for(x in f.selectedActions){var c=f.selectedActions[x];c!=a&&b.push(c)}f.selectedActions=b},this.refreshHumanPerspective=function(){for(x in f.entities){var a,b=f.entities[x];for(y in f.actionLists){var c=f.actionLists[y];if(c.entityName==b.name){a=c;break}}a.clear();var d=[];for(x in b.queuedActions){var e=b.queuedActions[x].split(";"),g=e[0];if(g.length>0){e.splice(0,1);var h=!0;e[0].length>0&&(d.push(e.join(";")),h=!1),a.addAction(g,h)}}b.queuedActions=d,w(b,a)}};var w=function(a,b){for(var c=0;c0&&(a.queuedActions.push(f.join(";")),h=!1),b.addAction(g,h)}}};this.createHumanPerspective=function(b,c){var d=$("
          ");d=$('
          '),$dialog=$('
          ').html(d).dialog({title:c,width:360,height:400,minHeight:200,minWidth:360,buttons:[{id:"btn-refresh",text:"Refresh actions",click:function(){a.plugins.ADM.refreshHumanPerspective()}},{id:"btn-step",text:"Step",click:function(){v()}}]}),f.actionLists=new Array;for(x in f.entities){var b=f.entities[x].name;f.actionLists.push(new EdenUI.plugins.ADM.ActionsList(b))}a.plugins.ADM.refreshHumanPerspective()};var z=function(){for(x in f.selectedEntities)s(f.selectedEntities[x]);alert("Entities successfully deleted."),f.selectedEntities=new Array};this.entityPush=function(a){f.selectedEntities.push(a)},this.entityRemove=function(a){var b=new Array;for(x in f.selectedEntities){var c=f.selectedEntities[x];c!=a&&b.push(c)}f.selectedEntities=b};var A=function(){return'
          '};this.createInstanceList=function(a,b){var c=$("
          ");c.html(A()),$dialog=$('
          ').html(c).dialog({title:b,width:360,height:400,minHeight:200,minWidth:360,buttons:[{id:"btn-delete-entity",text:"Delete selected",click:function(){z()}}]}),f.entityList=new EdenUI.plugins.ADM.EntityList;for(x in f.entities){var d=f.entities[x];f.entityList.addEntity(d.name,d.definitions.join("\n"),d.actionsArr.join("\n"))}};var B=function(a){var b=a.split(":")[1];return D(b.split("(")[0])},C=function(a){var b=a.split(":")[1].split("(")[1];return b.length>1?b.split(")")[0].split(","):[]},D=function(a){for(;32==a.charCodeAt(0)||9==a.charCodeAt(0);)a=a.substring(1,a.length);for(;32==a.charCodeAt(a.length-1)||9==a.charCodeAt(a.length-1);)a=E(a);return a},E=function(a){return a.substring(0,a.length-1)},F=function(a,b,c,e){for(x in f.templates)if(f.templates[x].name==a)return alert("Templates must have unique names."),-1;var h=g(a,e),i=new d(a,b,c,h);return f.templates.push(i),null!=f.templateList&&f.templateList.addTemplate(a,b),1},G=function(a){var b,c=a.split("\n"),d=new Array,e=new Array,f=new Array,g=!1,h=!1,i=!1;for(x in c){var j=c[x];if(j=D(j),""!=j)if(0==i)if("{"==j[0])i=!0,j.indexOf("name:")!=-1&&(b=B(j),d=C(j));else{var k=j.split("(")[0],l=j.split("(")[1].split(")")[0],m=E(D(j.split("as")[1])),n=t(k,l,m);if(n==-1)break}else if(1==g){var o=j.indexOf("}");o!=-1&&(j=E(j),g=!1),j.length>0&&e.push(j)}else if(1==h){var o=j.indexOf("}");o!=-1&&(j=E(j),h=!1),j.length>0&&f.push(j)}else if("}"==j[0]){i=!1;var n=F(b,d,e,f);if(b="",d=new Array,e=new Array,f=new Array,n==-1)return}else if(j.indexOf("name:")!=-1)b=B(j),d=C(j);else if(j.indexOf("definitions:")!=-1||j.indexOf("defs:")!=-1){if(g=!0,j=D(j),j.split("{").length>1){var p=D(j.split("{")[1]);p.indexOf("}")!=-1&&(p=E(p),g=!1),p.length>0&&e.push(p)}}else if(j.indexOf("actions:")!=-1&&(h=!0,j=D(j),j.split("{").length>1)){var p=D(j.split("{")[1]),o=p.indexOf("}");o!=-1&&(p=E(p),h=!1),p.length>0&&f.push(p)}}};this.createAdvancedInput=function(a,b){var c=document.createElement("textarea");c.style.boxSizing="border-box",c.style.width="100%",c.style.height="100%",$code_entry=$('
          '),$code_entry.append(c),$dialog=$('
          ').html($code_entry).dialog({title:b,width:360,height:400,minHeight:200,minWidth:360,buttons:[{id:"btn-submit-advanced",text:"Submit",click:function(){var a=c.value;G(a),c.value=""}}]}),input_dialog=$dialog,$("#btn-submit-advanced").css("margin-right","30px")},a.addViewCategory("adm","Abstract Definitive Machine"),a.views.AdmTemplateCreator={dialog:this.createTemplateCreator,title:"ADM Template Creator",category:a.viewCategories.adm},a.views.AdmInstantiator={dialog:this.createInstantiator,title:"ADM Template Instantiator",category:a.viewCategories.adm},a.views.AdmHumanPerspective={dialog:this.createHumanPerspective,title:"ADM Human Perspective",category:a.viewCategories.adm},a.views.AdmEntityList={dialog:this.createInstanceList,title:"ADM Entity List",category:a.viewCategories.adm},a.views.AdmAdvancedInput={dialog:this.createAdvancedInput,title:"ADM Advanced Input",category:a.viewCategories.adm},b()},EdenUI.plugins.ADM.TemplateList=function(){this.templateList=document.getElementById("template-menu"),this.templateList.style.minWidth="100px",this.templates=new Array},EdenUI.plugins.ADM.TemplateList.prototype.addTemplate=function(a,b){var c=new EdenUI.plugins.ADM.Template(a,b);c.element.appendTo(this.templateList),this.templates.push(c)},EdenUI.plugins.ADM.Template=function(a,b){this.template=a,this.element=$("");var c=this.showParamInput;this.element.click(function(){c(b)});var d=document.getElementById("instantiate-params");""==d.innerHTML&&c(b)},EdenUI.plugins.ADM.Template.prototype.showParamInput=function(a){var b=document.getElementById("instantiate-params");b.innerHTML="";for(x in a){var c=a[x],d=document.createElement("label");d.innerHTML=c+":",b.appendChild(d);var e=document.createElement("input");e.type="text",b.appendChild(e);var f=document.createElement("br");b.appendChild(f)}},EdenUI.plugins.ADM.ActionsList=function(a){var b=document.getElementById("human-perspective");this.actionresults=document.createElement("div"),this.actionresults.setAttribute("id","actions_"+a),this.actionresults.innerHTML="",b.appendChild(this.actionresults),this.actions=new Array,this.entityName=a},EdenUI.plugins.ADM.ActionsList.prototype.addAction=function(a,b){var c=new EdenUI.plugins.ADM.Action(a,b);c.element.appendTo(this.actionresults),this.actions.push(c)},EdenUI.plugins.ADM.ActionsList.prototype.clear=function(){this.actions=new Array,this.actionresults.innerHTML=""},EdenUI.plugins.ADM.ActionsList.prototype.remove=function(){var a=document.getElementById("human-perspective");a.removeChild(document.getElementById("actions_"+this.entityName))},EdenUI.plugins.ADM.Action=function(a,b){var a=a;this.action=a,this.element=$('
          '),this.update=this.updateAction;var c=!1;this.element.hover(function(){0==c?$(this).animate({backgroundColor:"#eaeaea"},100):$(this).animate({backgroundColor:"#66CCCC"},100)},function(){0==c?$(this).animate({backgroundColor:"white"},100):$(this).animate({backgroundColor:"#6666CC"},100)}).click(function(){0==c?(edenUI.plugins.ADM.actionPush(a),$(this).css("backgroundColor","#6666CC"),c=!0):(edenUI.plugins.ADM.actionRemove(a),$(this).css("backgroundColor","white"),c=!1)}),this.update(b)},EdenUI.plugins.ADM.Action.prototype.updateAction=function(a){var b='
        3. ';b=1==a?b+this.action+"
        4. ":b+this.action+" ... ",this.element.html(b)},EdenUI.plugins.ADM.EntityList=function(){this.entityList=document.getElementById("entity-list"),this.entities=new Array},EdenUI.plugins.ADM.EntityList.prototype.addEntity=function(a,b,c){var d=new EdenUI.plugins.ADM.Entity(a,b,c);d.element.appendTo(this.entityList),this.entities.push(d)},EdenUI.plugins.ADM.EntityList.prototype.removeEntity=function(a){var b;for(x in this.entities)if(this.entities[x].entity==a){b=x;break}this.entities.splice(b,1);var c=document.getElementById("element-"+a);this.entityList.removeChild(c)},EdenUI.plugins.ADM.EntityList.prototype.unselectAll=function(){for(x in this.entities)this.entities[x].unselect()},EdenUI.plugins.ADM.Entity=function(a,b,c){this.entity=a,this.element=$('
          ");var d='
        5. '+this.entity+"
        6. ";this.element.html(d);var b=b,c=c,e=!1;this.element.hover(function(){0==e?$(this).animate({backgroundColor:"#eaeaea"},100):$(this).animate({backgroundColor:"#66CCCC"},100)},function(){0==e?$(this).animate({backgroundColor:"white"},100):$(this).animate({backgroundColor:"#6666CC"},100)}).click(function(){if(this.innerHTML==d){var f=document.createElement("div");f.innerHTML="
          \t\t\t\t\t
          \t\t\t\t\t
          \t\t\t\t\t
          ",this.appendChild(f),edenUI.plugins.ADM.entityPush(a),$(this).css("backgroundColor","#6666CC"),e=!0}else this.innerHTML=d,edenUI.plugins.ADM.entityRemove(a),$(this).css("backgroundColor","white"),e=!1})},EdenUI.plugins.ADM.Entity.prototype.unselect=function(){var a='
        7. '+this.entity+"
        8. ";this.element.html(a)},EdenUI.plugins.ADM.title="Abstract Definitive Machine",EdenUI.plugins.ADM.description="Abstract Definitive Machine",EdenUI.plugins.ADM.author="Ruth King",EdenUI.plugins.DBView=function(a,b){this.createDialog=function(a,b){function c(){0==Array.isArray(j)&&(j=[["Value"],[[j]]]);for(var a=f.get(0);a.firstChild;)a.removeChild(a.firstChild);if(g=j[0],h=j[1],Array.isArray(g)||(h=j,g=[["List"]]),Array.isArray(h)){for(var b=$(""),c=0;c");d.html(g[c]),d.appendTo(b)}b.appendTo(f);for(var e=0;e"),c=0;c'):$(""),k.appendTo(i);var l=Array.isArray(h[e])?h[e][c]:h[e];k.html("
          "+Eden.edenCodeForValue(l)+"
          ")}i.appendTo(f)}}}function d(){f.find(".dbview-dependant").removeClass("dbview-dependant"),f.find(".dbview-dependency").removeClass("dbview-dependency")}var e=$('
          Query:
          '),f=$('
          ');f.appendTo(e);var g,h,i=e.find(".dbview-select-text").get(0),j=void 0,k=a.slice(0,-7),l=new Eden.Agent((void 0),"view/db/"+k+"/config"),m="_view_"+k+"_source";return l.declare(m),f.on("input","td",function(a){var b=a.target.cellIndex,c=a.target.parentNode.rowIndex-1;if(!(b<0||c<0)){a.target.textContent}}).on("mouseenter","td",function(a){a.target.cellIndex,a.target.parentNode.rowIndex-1}).on("mouseleave","td",function(a){d()}),e.on("input",".dbview-select-text",function(a){l.setSource("_view_"+k+"_source is "+i.value),l.execute(!0,!0)}),j=l.state[m],c(),l.on(m,function(a,b){j=b,c()}),$('
          ').html(e).dialog({title:b,width:600,height:450,minHeight:120,minWidth:230,dialogClass:"dbview-dialog"}),{confirmClose:!0}},a.views.DBView={dialog:this.createDialog,title:"Database Viewer",category:a.viewCategories.visualization},b()},EdenUI.plugins.DBView.title="DBView",EdenUI.plugins.DBView.description="Display a table showing entire database contents.",EdenUI.plugins.SpeechSynthesis=function(a,b){function c(){var a=window.speechSynthesis.paused;window.speechSynthesis.cancel(),a&&window.speechSynthesis.pause()}function d(a,b){if(f)return void(f=!1);var e,g=root.lookup("speak"),h=root.lookup("speakingList"),i=root.lookup("speakingIndex"),j=root.lookup("speaking"),k=root.lookup("speakingID"),l=root.lookup("speakingText"),m=root.lookup("speakingSpeech"),n=root.lookup("speakingCharIndex"),o=h.value(),p=i.value();if(c(),p||(p=1),""!=a){if("finished"==a){var q=l.value();"string"==typeof q&&n.assign(q.length+1,g)}else"interrupted"==a&&(f=!0);e=k.value(),eden.isValidIdentifier(e)&&root.lookup(e+"_status").assign(a,g)}if(b&&p++,n.assign(1,g),root.lookup("speakingTime").assign(0,g),Array.isArray(o)&&p<=o.length){j.value()||j.assign(!0,g);var r=o[p-1];if(!(r instanceof SpeakingWords)||r.cancelled)return void d("",!0);r.prepareUtterance();var s=r.utterance;e=r.id,k.assign(e,g),eden.isValidIdentifier(e)&&root.lookup(e+"_status").assign("speaking",g),l.assign(s.text,g),m.assign(r,g),b&&i.assign(p,g),r.hasBeenSpoken=!0,window.speechSynthesis.speak(s)}else j.assign(!1,g),k.assign("",g),l.assign("",g),m.assign(void 0,g),Array.isArray(o)&&i.assign(o.length+1,g)}function e(a,b){var c,d,e,f,g=window.speechSynthesis.getVoices();a&&(a=a.toLowerCase(),d=a.indexOf("-"),d!=-1?(e=a.slice(0,d),f=!0):(e=a,f=!1)),b&&(c=new RegExp("\\b"+b+"\\b","i"));for(var h=void 0,i=!1,j=!1,k=!1,l=!1,m=0;mb.length+1)e.assign(b.length+1,c);else if(f<=b.length){for(var g=f<1?0:f-1;g=1&&e<=128&&c.send([192+d,e-1])}b.length>16&&eden.error(new Error("MIDI programs list is too long."))}}function d(a){if(void 0===a)return p;if(Number.isInteger(a)){if(a<1||h&&a>k.length)throw new Error("No MIDI output device exists with device number "+a);return a-1}if(h&&"string"==typeof a){for(var b=0;bl.length)throw new Error("No MIDI input device exists with device number "+a);return a-1}if(h&&"string"==typeof a){for(var b=0;bw&&(x=new Array(w)),x[0]=a,B=1,C=0;else{var b,c=a.timeStamp;for(b=B-1;b>=C&&!(x[b].timeStamp<=c);b--);b==B-1?x[B]=a:x.splice(b+1,0,a),B++}D.assign(B-C)}var g=this,h=!1;Object.defineProperty(this,"initialized",{get:function(){return h},enumerable:!0});var j=[];this.addSoftwareDriver=function(a){console.log("New JavaScript MIDI driver registered."),j.push(a),h&&a()};var k=[],l=[],m=root.lookup("midiNumberOfOutputs");m.assign(0);var n=root.lookup("midiNumberOfInputs");n.assign(0);var o={};this.addSoftSynth=function(a){if(k.push(a),m.assign(k.length),console.log('Added software synthesizer "'+a.name+'".'),h){var b=k.length-1,d=o[b];void 0!==d&&c(b,d.value())}},this.addSoftInput=function(a){l.push(a),n.assign(l.length),console.log('Added software input "'+a.name+'".')};var p=0,q=0;Object.defineProperty(this,"outputNames",{get:function(){for(var a=[],b=0;b=127?127:Math.round(a):void 0},this.isValidNote=function(a){return Number.isInteger(a)&&a>=-20&&a<=107},this.loadPrograms=function(a,b){a=d(a);var c=k[a];if(!Array.isArray(b))throw new Error("MIDI programs must be given as a list.");for(var e=b.length,f=new Array(e),g=0;g=1&&h<=128))throw new Error("Item "+g+" must be an integer between 1 and 128.");f[g]=h-1}c.loadPrograms&&c.loadPrograms(f)},this.bindPrograms=function(a,b){if(!(a instanceof Symbol))throw new Error("The first argument must be a Symbol.");b=d(b),Array.isArray(a.value())||void 0!==a.definition||a.assign([1]);var e=function(a,d){return Array.isArray(d)?void(h&&c(b,d)):void eden.error(new Error("Illegal MIDI programs list: "+Eden.edenCodeForValue(d)))};e(a,a.value()),a.addJSObserver("bind",e),o[b]=a},this.getInputs=function(){return l};var r=!1,s=[],t=[];this.initialize=function(a,b){function d(a){if(a0&&j.send([144+c,e+20,g.roundValue(f)]):(f>0?(void 0!==i&&j.send([144+c,i+20,0]),h&&j.send([144+c,e+20,g.roundValue(f)])):f<0?void 0!==i&&j.send([128+c,i+20,g.roundValue(-f)]):void 0!==i&&j.send([144+c,i+20,0]),u[a]=e):void 0!==i&&j.send([144+c,i+20,0])},this.alterVelocity=function(a,b,c,e,f){var h=u[a];if(e===h&&void 0!==e){var i=k[d(b)];f>0?i.send([160+c,e+20,g.roundValue(f)]):f<0?i.send([128+c,e+20,g.roundValue(-f)]):i.send([144+c,e+20,0])}};var v={};v.volume=7,this.bindControlChange=function(a,b,c,e){function f(a,b){var d=g.roundValue(b);void 0!==d&&i.send([176+c,h,d])}if(!(a instanceof Symbol))throw new Error("The first argument must be a Symbol.");var h,i=k[d(b)];if("string"==typeof e){if(h=v[e.toLowerCase()],void 0===h)throw new Error("Unknown control name "+e)}else{if(!(Number.isInteger(e)&&e>=0&&e<=127))throw new Error("The control must be specified either as a string or as an integer between 0 and 127 inclusive.");h=e}f(a,a.value()),a.addJSObserver("bind",f)};var w=16,x=new Array(w),y=root.lookup("midiInputDevice"),z=root.lookup("midiInputTimestamp"),A=root.lookup("midiInputMessage"),B=0,C=0,D=root.lookup("midiInputMessageCount");this.startInput=function(a){if(void 0===a)for(i=0;i=2*w&&C>.8*c-1&&(x.splice(0,C),B-=C,C=0);var d,e=b.target;e&&(d=e.name),root.beginAutocalcOff(),y.assign(d,a),z.assign(b.timeStamp,a),A.assign(b.data),D.assign(B-C),root.endAutocalcOff()}},this.clearInputMessages=function(){x.length>w&&(x=new Array(w)),B=0,C=0,D.assign(0)},Eden.Agent.importAgent("plugins/midi","default",[],b)},EdenUI.plugins.MIDI.title="MIDI",EdenUI.plugins.MIDI.description="Adds musical capabilities to JS-EDEN.",EdenUI.plugins.Debugger=function(a,b){this.createDialog=function(a,b){function c(a){var b="";return"when"==a.type&&a.base&&a.base.origin?(b+="## "+a.base.origin.name,a.line&&(b+=":"+(a.line+1)),b+="\n"):a.name&&(b+="## "+a.name+"\n"),a.getSource&&(b+=a.getSource()),b}var d=(a.slice(0,-7),!1),e=void 0,f=!1,g=500,h=$('
          '),i=$('
          ');h.append(i);var j=$('
          ');h.append(j);var k={},l=1,m=function(a){var b=a.agent,e=c(b);if(k[b.id]){var h=k[b.id].html;if(k[b.id].data=a,f=!1,h){var i=new Eden.AST(e,(void 0),b),j=new EdenUI.Highlight(h.get(0).childNodes[1]);if(j.highlight(i,-1,-1),a.statement){var l=a.statement.line-b.getLine(),m=h.get(0).childNodes[1].childNodes[l+1];m?m.className="eden-line debugger-line":console.error("Missing line: "+l)}}else console.error("Missing output")}d&&setTimeout(a.next,g)};Eden.AST.debugstep_cb=m;var n=function(a){var b=a.agent;void 0!==b.id&&(o(a),console.log("WHEN ALREADY LOGGED")),b.id=l,l++;var d=$('
          ');j.append(d),k[b.id]={html:d,data:a},void 0===e&&(e=k[b.id],d.get(0).className="debugger-agent active");var f=c(b),g=new Eden.AST(f,(void 0),b),h=new EdenUI.Highlight(d.get(0).childNodes[1]);h.highlight(g,-1,-1)};Eden.AST.debug_begin_cb=n;var o=function(a){var b=a.agent;if(void 0!==b.id&&void 0!==k[b.id]){e===k[b.id]&&(f=!1,e=void 0);var d=c(b),g=k[b.id].html,h=new Eden.AST(d,(void 0),b),i=new EdenUI.Highlight(g.get(0).childNodes[1]);i.highlight(h,-1,-1),k[b.id].html.remove(),delete k[b.id],b.id=void 0}};return Eden.AST.debug_end_cb=o,Eden.AST.debug=!0,Eden.AST.debugstep=!1,$('
          ').html(h).dialog({appendTo:"#jseden-views",title:b,width:590,height:500,minHeight:120,minWidth:230,dialogClass:"debugger-dialog"}),i.on("click",".play",function(a){d=!d,d?(a.currentTarget.innerHTML="",a.currentTarget.className="debugger-button play active"):(a.currentTarget.innerHTML="",a.currentTarget.className="debugger-button play")}).on("click",".stepforward",function(a){e&&e.data.next&&(e.data.next(),e&&(e.data.next=void 0))}).on("click",".debug",function(a){Eden.AST.debugstep=!Eden.AST.debugstep,Eden.AST.debugstep?a.currentTarget.className="debugger-button debug active":a.currentTarget.className="debugger-button debug"}).on("change",".debugger-speed",function(a){g=a.currentTarget.value,console.log("Change speed: "+g)}),j.on("click",".debugger-agent",function(a){e&&(e.html.get(0).className="debugger-agent"),e=k[a.currentTarget.getAttribute("data-agent")],e.html.get(0).className="debugger-agent active"}),{destroy:function(){Eden.AST.debug=!1}}},a.views.Debugger={dialog:this.createDialog,title:"Debugger",category:a.viewCategories.history},b()},EdenUI.plugins.Debugger.title="Debugger",EdenUI.plugins.Debugger.description="",EdenUI.plugins.Debugger.originalAuthor="Nicolas Pope",EdenUI.plugins.MIDIDotJS=function(a,b){function c(){a.plugins.MIDI.addSoftwareDriver(function(b,c){function f(e){e==i.length?(g=window.MIDI,g.loadPlugin({soundfontUrl:d,onsuccess:function(){a.plugins.MIDI.addSoftSynth(h),b&&b.apply(this,c)}})):$.ajax({url:"plugins/midi/emulation/lib/MIDI.js/"+i[e],success:function(){f(e+1)}})}var g,h={};h.name="MIDI.js",h.loadPrograms=function(a){for(var b=0;b0)window.setTimeout(function(){var a=b(h);d.onmidimessage(a),c(g+1)},i);else{var j=b(h);d.onmidimessage(j),c(g+1)}}}var e=window.performance.now(),f=a.length;c(0)},a.plugins.MIDI?c():a.loadPlugin("MIDI",c)},EdenUI.plugins.MIDIFileInput.title="MIDI File Input",EdenUI.plugins.MIDIFileInput.description="Use a MIDI file to simulate MIDI file input."; \ No newline at end of file