!function(GLOBAL,MODULE,DEFINE){var _cs=function(){},$cs=function(){return _cs.hook("ComponentJS:lookup","pass",_cs.lookup.apply(GLOBAL,arguments))};$cs.pattern={},$cs.symbol=function(){var e;e=void 0;var t=null;return function(n){return null!==t&&(GLOBAL[t]=e),void 0===n||""===n?t=null:(e=GLOBAL[t=n],GLOBAL[t]=$cs),$cs}}(),$cs.ns=function(e,t){if("string"!=typeof e||""===e)throw"invalid namespace path";var n=e.split("."),s=n.length;void 0!==t&&s--;for(var o=0,i=GLOBAL;o<s;)void 0===i[n[o]]&&(i[n[o]]={}),i=i[n[o++]];return void 0!==t&&(i[n[o]]=t,i=t),i},$cs.version={major:1,minor:6,micro:2,date:20180403},_cs.exception=function(e,t){var n;return $cs.debug()>0&&"object"==typeof GLOBAL.console&&("function"==typeof GLOBAL.console.trace?GLOBAL.console.trace():void 0!==GLOBAL.printStackTrace&&"function"==typeof GLOBAL.console.log&&(n=GLOBAL.printStackTrace(),GLOBAL.console.log(n.join("\n")))),new Error("[ComponentJS]: ERROR: "+e+": "+t)},_cs.log=function(e){_cs.hook("ComponentJS:log","or",e)||(void 0!==GLOBAL.console&&void 0!==GLOBAL.console.log?GLOBAL.console.log("[ComponentJS]: "+e):void 0!==GLOBAL.Titanium&&void 0!==GLOBAL.Titanium.API&&"function"==typeof GLOBAL.Titanium.API.log&&GLOBAL.Titanium.API.log("[ComponentJS]: "+e))},$cs.debug=function(){var e=0;return function(t,n){if(0===arguments.length)return e;if(1===arguments.length)e=t;else if(t<=e){for(var s="",o=1;o<t;o++)s+="    ";_cs.log("DEBUG["+t+"]: "+s+n)}}}(),_cs.nop=function(){},_cs.annotation=function(e,t,n){var s=null,o="__ComponentJS_"+t+"__";return void 0!==e&&null!==e&&(void 0!==e[o]&&(s=e[o]),void 0!==n&&(null!==n?e[o]=n:delete e[o])),s},_cs.isdefined=function(e){return void 0!==e},_cs.isown=function(e,t){var n=Object.hasOwnProperty.call(e,t);return"constructor"!==t&&"prototype"!==t||(n=n&&Object.propertyIsEnumerable.call(e,t),-1!==e[t].toString().indexOf("[native code]")&&(n=!1)),n},_cs.istypeof=function(e){var t=typeof e;return"object"===t?null===e?t="null":"[object String]"===Object.prototype.toString.call(e)?t="string":"[object Number]"===Object.prototype.toString.call(e)?t="number":"[object Boolean]"===Object.prototype.toString.call(e)?t="boolean":"[object Function]"===Object.prototype.toString.call(e)?t="function":"[object Array]"===Object.prototype.toString.call(e)?t="array":null!==_cs.annotation(e,"type")&&(t=_cs.annotation(e,"type")):"function"===t&&null!==_cs.annotation(e,"type")&&(t=_cs.annotation(e,"type")),t},_cs.keysof=function(e){var t=[];for(var n in e)_cs.isown(e,n)&&t.push(n);return t},_cs.json=function(){var e=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,t={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},n=function(n){return e.lastIndex=0,e.test(n)?'"'+n.replace(e,function(e){var n=t[e];return"string"==typeof n?n:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+n+'"'};return function(e){return function(e,t){if("boolean"!=typeof e&&"number"!=typeof e&&"string"!=typeof e){if(void 0!==t[e])return"null /* CYCLE! */";t[e]=!0}switch(typeof e){case"boolean":e=String(e);break;case"number":e=isFinite(e)?String(e):"NaN";break;case"string":e=n(e);break;case"function":e=null!==_cs.annotation(e,"type")?"<"+_cs.annotation(e,"type")+">":"<function>";break;case"object":var s=[];if(null===e)e="null";else if(null!==_cs.annotation(e,"type"))e="<"+_cs.annotation(e,"type")+">";else if("[object Function]"===Object.prototype.toString.call(e))e="<function>";else if("[object Array]"===Object.prototype.toString.call(e)||e instanceof Array){for(var o=0;o<e.length;o++)s[o]=arguments.callee(e[o],t);e=0===s.length?"[]":"["+s.join(",")+"]"}else{for(var i in e)if(Object.hasOwnProperty.call(e,i)){var a=arguments.callee(e[i],t);s.push(n(i)+":"+a)}e=0===s.length?"{}":"{"+s.join(",")+"}"}break;default:e="<unknown>"}return e}(e,{})}}(),_cs.clone=function(e,t){if(void 0===t)t=function(){return!0};else if("string"==typeof t){var n=t;t=function(e){return e.match(n)}}var s,o=arguments.callee,i=function(e,t){var n=function(){return e.apply(this,arguments)};n.prototype=e.prototype;for(var s in e)_cs.isown(e,s)&&(n[s]=t(s,e)?o(e[s],t):e[s]);return _cs.annotation(n,"clone",!0),n};if(s=void 0,"function"==typeof e)s=i(e,t);else if("object"==typeof e)if(null===e)s=null;else if("[object String]"===Object.prototype.toString.call(e))s=""+e.valueOf();else if("[object Number]"===Object.prototype.toString.call(e))s=0+e.valueOf();else if("[object Boolean]"===Object.prototype.toString.call(e))s=!!e.valueOf();else if("[object Function]"===Object.prototype.toString.call(e))s=i(e,t);else if("[object Date]"===Object.prototype.toString.call(e))s=new Date(e.getTime());else if("[object RegExp]"===Object.prototype.toString.call(e))s=new RegExp(e.source);else if("[object Array]"===Object.prototype.toString.call(e)){var a=e.length;s=[];for(var r=0;r<a;r++)s.push(o(e[r],t))}else{s={};for(var c in e)"constructor"!==c&&_cs.isown(e,c)&&(t(c,e)?s[c]=o(e[c],t):s[c]=e[c]);"function"==typeof e.constructor&&(s.constructor=e.constructor),"object"==typeof e.prototype&&(s.prototype=e.prototype)}else s=e;return s},_cs.extend=function(e,t,n){if(void 0===n)n=function(){return!0};else if("string"==typeof n){var s=n;n=function(e){return e.match(s)}}for(var o in t)_cs.isown(t,o)&&n(o,t[o])&&(e[o]=t[o]);return e},_cs.mixin=function(e,t,n){if(void 0===n)n=function(){return!0};else if("string"==typeof n){var s=n;n=function(e){return e.match(s)}}for(var o in t)if(_cs.isown(t,o)&&n(o,t[o]))if("function"===_cs.istypeof(t[o])){var i=_cs.clone(t[o],n);_cs.annotation(i,"name",o),"function"===_cs.istypeof(e[o])&&_cs.isown(e,o)&&_cs.annotation(i,"base",e[o]),e[o]=i}else e[o]=t[o];return e},_cs.concat=function(){for(var e=[],t=0;t<arguments.length;t++)for(var n=arguments[t],s=0;s<n.length;s++)e.push(n[s]);return e},_cs.slice=function(e,t,n){var s=[];void 0===n&&(n=e.length);for(var o=t;o<n;o++)s.push(e[o]);return s},_cs.map=function(e,t){for(var n=[],s=0;s<e.length;s++)n.push(t(e[s],s));return n},_cs.filter=function(e,t){for(var n=[],s=0;s<e.length;s++)t(e[s],s)&&n.push(e[s]);return n},_cs.foreach=function(e,t){for(var n=0;n<e.length;n++)t(e[n],n)},_cs.token=function(){this.name="",this.text="",this.tokens=[],this.pos=0,this.len=0},_cs.token.prototype={setName:function(e){this.name=e},setText:function(e){this.text=e},addToken:function(e,t,n,s,o){this.tokens.push({b1:e,b2:t,e2:n,e1:s,symbol:o}),this.len++},peek:function(e){if(void 0===e&&(e=0),e>=this.len)throw _cs.exception(this.name,"parse error: not enough tokens");return this.tokens[this.pos+e].symbol},skip:function(e){if(void 0===e&&(e=1),e>this.len)throw _cs.exception(this.name,"parse error: not enough tokens available to skip: "+this.ctx());this.pos+=e,this.len-=e},consume:function(e){if(this.len<=0)throw _cs.exception(this.name,"parse error: no more tokens available to consume: "+this.ctx());if(this.tokens[this.pos].symbol!==e)throw _cs.exception(this.name,'parse error: expected token symbol "'+e+'": '+this.ctx());this.pos++,this.len--},ctx:function(e){void 0===e&&(e=78);var t=this.tokens[this.pos],n="<"+this.text.substr(t.b2,t.e2-t.b2+1)+">";n=this.text.substr(t.b1,t.b2-t.b1)+n;var s=e-(n+=this.text.substr(t.e2+1,t.e1-t.e2)).length;if(s>0){s=Math.floor(s/2);var o,i;if(this.pos>0){var a=0;for(o=this.pos-1;o>=0&&(t=this.tokens[o],!((a+=(i=this.text.substr(t.b1,t.e1-t.b1+1)).length)>s));o--)n=i+n;o>0&&(n="[...]"+n)}if(this.len>1){var r=0;for(o=this.pos+1;o<this.pos+this.len&&(t=this.tokens[o],!((r+=(i=this.text.substr(t.b1,t.e1-t.b1+1)).length)>s));o++)n+=i;o<this.pos+this.len&&(n+="[...]")}}return n=n.replace(/\r/,"\\r").replace(/\n/,"\\n").replace(/\t/,"\\t")}},$cs.validate=function(e,t){if("object"==typeof t&&t instanceof RegExp)return t.test(e.toString());if("function"==typeof t)return t(e);if("string"==typeof t)return _cs.validate_at(e,t);throw _cs.exception("validate",'invalid specification argument: "'+t+'"')},_cs.validate_at=function(e,t,n){var s=_cs.validate_cache[t];if(void 0===s&&(s=_cs.validate_compile(t),_cs.validate_cache[t]=s),void 0!==n){var o="string"==typeof n?_cs.select_parse(n):n;s=_cs.validate_subset(s,o)}return _cs.validate_executor.exec_spec(e,s)},_cs.validate_cache={},_cs.validate_compile=function(e){var t=_cs.validate_tokenize(e);return _cs.validate_parser.parse_spec(t)},_cs.validate_tokenize=function(e){var t=new _cs.token;t.setName("validate"),t.setText(e);for(var n,s=0;""!==e;){if(null===(n=e.match(/^(\s*)([^{}\[\]:,?*+()!|\s]+|[{}\[\]:,?*+()!|])(\s*)/)))throw _cs.exception("validate",'parse error: cannot further canonicalize: "'+e+'"');t.addToken(s,s+n[1].length,s+n[1].length+n[2].length-1,s+n[0].length-1,n[2]),e=e.substr(n[0].length),s+=n[0].length}return t},_cs.validate_parser={parse_spec:function(e){if(e.len<=0)return null;var t,n=e.peek();if("!"===n)t=this.parse_not(e);else if("("===n)t=this.parse_group(e);else if("{"===n)t=this.parse_hash(e);else if("["===n)t=this.parse_array(e);else if(n.match(/^(?:null|undefined|boolean|number|string|function|object)$/))t=this.parse_primary(e);else if(n.match(/^(?:clazz|trait|component)$/))t=this.parse_special(e);else if("any"===n)t=this.parse_any(e);else{if(!n.match(/^[A-Z][_a-zA-Z$0-9]*$/))throw _cs.exception("validate",'parse error: invalid token symbol: "'+e.ctx()+'"');t=this.parse_class(e)}return t},parse_not:function(e){e.consume("!");var t=this.parse_spec(e);return t={type:"not",op:t}},parse_group:function(e){e.consume("(");for(var t=this.parse_spec(e);"|"===e.peek();){e.consume("|");t={type:"or",op1:t,op2:this.parse_spec(e)}}return e.consume(")"),t},parse_hash:function(e){e.consume("{");for(var t=[];"}"!==e.peek();){var n=this.parse_key(e),s=this.parse_arity(e,"?");e.consume(":");var o=this.parse_spec(e);if(t.push({type:"element",key:n,arity:s,element:o}),","!==e.peek())break;e.skip()}var i={type:"hash",elements:t};return e.consume("}"),i},parse_array:function(e){e.consume("[");for(var t=[];"]"!==e.peek();){var n=this.parse_spec(e),s=this.parse_arity(e,"?*+");if(t.push({type:"element",element:n,arity:s}),","!==e.peek())break;e.skip()}var o={type:"array",elements:t};return e.consume("]"),o},parse_primary:function(e){var t=e.peek();if(!t.match(/^(?:null|undefined|boolean|number|string|function|object)$/))throw _cs.exception("validate",'parse error: invalid primary type "'+t+'"');return e.skip(),{type:"primary",name:t}},parse_special:function(e){var t=e.peek();if(!t.match(/^(?:clazz|trait|component)$/))throw _cs.exception("validate",'parse error: invalid special type "'+t+'"');return e.skip(),{type:"special",name:t}},parse_any:function(e){var t=e.peek();if("any"!==t)throw _cs.exception("validate",'parse error: invalid any type "'+t+'"');return e.skip(),{type:"any"}},parse_class:function(e){var t=e.peek();if(!t.match(/^[A-Z][_a-zA-Z$0-9]*$/))throw _cs.exception("validate",'parse error: invalid class type "'+t+'"');return e.skip(),{type:"class",name:t}},parse_arity:function(e,t){var n=[1,1];if(e.len>=5&&"{"===e.peek(0)&&e.peek(1).match(/^[0-9]+$/)&&","===e.peek(2)&&e.peek(3).match(/^(?:[0-9]+|oo)$/)&&"}"===e.peek(4))n=[parseInt(e.peek(1),10),"oo"===e.peek(3)?Number.MAX_VALUE:parseInt(e.peek(3),10)],e.skip(5);else if(e.len>=1&&1===e.peek().length&&t.indexOf(e.peek())>=0){switch(e.peek()){case"?":n=[0,1];break;case"*":n=[0,Number.MAX_VALUE];break;case"+":n=[1,Number.MAX_VALUE]}e.skip()}return n},parse_key:function(e){var t=e.peek();if(!t.match(/^(?:[_a-zA-Z$][_a-zA-Z$0-9]*|@)$/))throw _cs.exception("validate",'parse error: invalid key "'+t+'"');return e.skip(),t}},_cs.validate_subset=function(e,t){var n,s,o,i;for(n=0,s=t.length;n<s;n++)if("hash"===e.type){var a=!1;for(o=0,i=e.elements.length;o<i;o++){if(e.elements[o].key===t[n]){e=e.elements[o].element,a=!0;break}"@"===e.elements[o].key&&(e=e.elements[o].element,a=!0)}if(!a)throw _cs.exception("validate",'dereference error: hash key "'+t[n]+'" not found')}else{if("array"!==e.type)throw _cs.exception("validate",'dereference error: no more hash or array to be dereferenced by "'+t[n]+'"');if((o=parseInt(t[n],10))>=e.elements.length)throw _cs.exception("validate","dereference error: array index #"+o+' ("'+t[n]+'") not found');e=e.elements[o].element}return e},_cs.validate_executor={exec_spec:function(e,t){var n=!1;if(null!==t)switch(t.type){case"not":n=this.exec_not(e,t);break;case"or":n=this.exec_or(e,t);break;case"hash":n=this.exec_hash(e,t);break;case"array":n=this.exec_array(e,t);break;case"primary":n=this.exec_primary(e,t);break;case"special":n=this.exec_special(e,t);break;case"class":n=this.exec_class(e,t);break;case"any":n=!0;break;default:throw _cs.exception("validate",'invalid validation AST: node has unknown type "'+t.type+'"')}return n},exec_not:function(e,t){return!this.exec_spec(e,t.op)},exec_or:function(e,t){return this.exec_spec(e,t.op1)||this.exec_spec(e,t.op2)},exec_hash:function(e,t){var n,s,o="object"==typeof e,i={};if(o)for(n=0;n<t.elements.length;n++)if(i[(s=t.elements[n]).key]=s.element,s.arity[0]>0&&("@"===s.key&&0===_cs.keysof(e).length||"@"!==s.key&&void 0===e[s.key])){o=!1;break}if(o)for(var a in e)if(Object.hasOwnProperty.call(e,a)&&Object.propertyIsEnumerable.call(e,a)&&"constructor"!==a&&"prototype"!==a&&!(void 0!==i[a]&&this.exec_spec(e[a],i[a])||void 0!==i["@"]&&this.exec_spec(e[a],i["@"]))){o=!1;break}return o},exec_array:function(e,t){var n,s,o="object"==typeof e&&e instanceof Array;if(o){var i=0;for(n=0;n<t.elements.length;n++){s=t.elements[n];for(var a=0;a<s.arity[1]&&i<e.length&&this.exec_spec(e[i],s.element);)a++,i++;if(a<s.arity[0]){o=!1;break}}i<e.length&&(o=!1)}return o},exec_primary:function(e,t){return"null"===t.name&&null===e||typeof e===t.name},exec_class:function(value,node){return"object"==typeof value&&Object.prototype.toString.call(value)==="[object "+node.name+"]"||eval("value instanceof "+node.name)},exec_special:function(e,t){var n=!1;return typeof e==("component"===t.name?"object":"function")&&(n=_cs.annotation(e,"type")===t.name),n}},$cs.params=function(e,t,n){_cs.hook("ComponentJS:params:"+e+":enter","none",{args:t,spec:n});var s,o={},i=0,a=0,r={};for(s in n)if(_cs.isown(n,s)&&(void 0!==n[s].pos&&(r[n[s].pos]=s,"number"==typeof n[s].pos&&i++,void 0!==n[s].req&&n[s].req&&a++),void 0!==n[s].def)){if(void 0!==n[s].valid&&!$cs.validate(n[s].def,n[s].valid))throw _cs.exception(e,'parameter "'+s+'" has default value '+_cs.json(n[s].def)+', which does not validate against validation specification "'+n[s].valid+'"');o[s]=n[s].def}var c=!1;if(1===t.length&&"object"===_cs.istypeof(t[0])){c=!0;for(s in t[0])_cs.isown(t[0],s)&&void 0===n[s]&&(c=!1)}var p,l,u=function(e,t,n,s){if(void 0!==s&&!$cs.validate(n,s))throw _cs.exception(e,'parameter "'+t+'" has value '+_cs.json(n)+', which does not validate against "'+s+'"')};if(c){l=t[0];for(s in l)if(_cs.isown(l,s)){if(void 0===n[s])throw _cs.exception(e,'unknown parameter "'+s+'"');u(e,s,l[s],n[s].valid),o[s]=l[s]}for(s in n)if(_cs.isown(n,s)&&void 0!==n[s].req&&n[s].req&&void 0===l[s])throw _cs.exception(e,'required parameter "'+s+'" missing')}else{if(t.length<a)throw _cs.exception(e,"invalid number of arguments (at least "+a+" required)");for(p=0;p<i&&p<t.length;p++)u(e,r[p],t[p],n[r[p]].valid),o[r[p]]=t[p];if(p<t.length){if(void 0===r["..."])throw _cs.exception(e,"too many arguments provided");for(l=[];p<t.length;p++)l.push(t[p]);u(e,r["..."],l,n[r["..."]].valid),o[r["..."]]=l}}return _cs.hook("ComponentJS:params:"+e+":leave","none",{args:t,spec:n,params:o}),o},_cs.base16_number=function(e,t,n){var s="";void 0===t&&(t=0),void 0===n&&(n=!1);for(var o=n?"0123456789ABCDEF":"0123456789abcdef";e>0||t>0;)s=o.charAt(Math.floor(e%16))+s,e=Math.floor(e/16),t>0&&t--;return s},_cs.cid=function(){var e=[0,0,0,0];return function(){e[3]++;for(var t=0,n=3;n>=0;n--)t+=e[n],e[n]=Math.floor(t%4294967296),t=Math.floor(t/4294967296);return _cs.base16_number(e[0],8,!0)+_cs.base16_number(e[1],8,!0)+_cs.base16_number(e[2],8,!0)+_cs.base16_number(e[3],8,!0)}}(),_cs.proxy=function(e,t,n){"string"===_cs.istypeof(t)&&"object"===_cs.istypeof(e)&&"function"===_cs.istypeof(e[t])&&(t=e[t]),_cs.isdefined(n)||(n=!1);var s=function(){var o=function(){return"object"===_cs.istypeof(arguments.callee.__ctx__)&&(arguments.callee.__ctx__.__this__=this),t.apply(arguments.callee.__ctx__,arguments)};return o.__ctx__=n?_cs.clone(_cs.isdefined(this.__ctx__)?this.__ctx__:e):e,n&&(o.clone=s),o.guid=t.guid=t.guid||o.guid||_cs.cid(),o};return s.call({})},_cs.memoize=function(e){var t=function(){var t,n=_cs.json(_cs.slice(arguments,0));return t=void 0,void 0!==arguments.callee.cache[n]?t=arguments.callee.cache[n]:(t=e.apply(this,arguments),arguments.callee.cache[n]=t),t};return t.cache={},t},_cs.curry=function(e){var t=_cs.slice(arguments,1);return function(){var n=_cs.slice(arguments,0),s=_cs.concat(t,n);return e.apply(this,s)}},$cs.attribute=function(){var e=$cs.params("attribute",arguments,{name:{pos:0,req:!0,valid:"string"},def:{pos:1,req:!0,valid:"any"},valid:{pos:2,def:void 0,valid:"(function|RegExp|string)"}});return _cs.proxy({value:e.def},function(t){var n=this.value;if(arguments.length>0){if(void 0!==e.valid&&!$cs.validate(t,e.valid))throw _cs.exception("attribute",'invalid value "'+t+'" for attribute "'+e.name+'"');this.value=t;var s=this.__this__;void 0!==s&&"function"==typeof s.notify&&s.notify.call(s,"attribute:set:"+e.name,t,n,e.name)}return n},!0)},_cs.hooks={},_cs.hook_proc={none:{init:void 0,step:function(){}},pass:{init:function(e){return e[0]},step:function(e,t){return t}},or:{init:!1,step:function(e,t){return e||t}},and:{init:!0,step:function(e,t){return e&&t}},mult:{init:1,step:function(e,t){return e*t}},add:{init:0,step:function(e,t){return e+t}},append:{init:"",step:function(e,t){return e+t}},push:{init:[],step:function(e,t){return e.push(t),e}},concat:{init:[],step:function(e,t){return _cs.concat(e,t)}},insert:{init:{},step:function(e,t){return e[t]=!0,e}},extend:{init:{},step:function(e,t){return _cs.extend(e,t)}}},_cs.latch=function(e,t){if(arguments.length<2)throw _cs.exception("latch(internal)","missing arguments");void 0===_cs.hooks[e]&&(_cs.hooks[e]=[]);var n=_cs.slice(arguments,2),s=_cs.cid();return _cs.hooks[e].push({id:s,cb:t,args:n}),s},_cs.unlatch=function(e,t){if(2!==arguments.length)throw _cs.exception("unlatch(internal)","invalid number of arguments");if(void 0===_cs.hooks[e])throw _cs.exception("unlatch(internal)","no such hook");for(var n=-1,s=0;s<_cs.hooks[e].length;s++)if(_cs.hooks[e][s].id===t){n=s;break}if(-1===n)throw _cs.exception("unlatch(internal)","no such latched callback");_cs.hooks[e]=_cs.hooks[e].splice(n,1)},_cs.hook=function(e,t){if(arguments.length<2)throw _cs.exception("hook(internal)","missing argument");if(void 0===_cs.hook_proc[t])throw _cs.exception("hook(internal)","no such result processing defined");var n=_cs.hook_proc[t].init,s=null;return"function"==typeof n&&(s=_cs.slice(arguments,2),n=n.call(null,s)),void 0!==_cs.hooks[e]&&(null===s&&(s=_cs.slice(arguments,2)),_cs.foreach(_cs.hooks[e],function(o){var i=o.cb.apply({args:o.args,result:n,hooks:_cs.hooks[e].length,_cs:_cs,$cs:$cs},s);n=_cs.hook_proc[t].step.call(null,n,i)})),n},$cs.select=function(e,t,n){var s="string"==typeof t?_cs.select_parse(t):t;return 2===arguments.length?_cs.select_path(e,s):_cs.select_path(e,s,n)},_cs.select_cache={},_cs.select_parse=function(e){var t=_cs.select_cache[e];if(void 0===t){t=[];for(var n,s=0,o=e;""!==o;){if(null!==(n=o.match(/^\s*(?:\.)?\s*([a-zA-Z$0-9_][a-zA-Z$0-9_:-]*)/)))t.push(n[1]);else if(null!==(n=o.match(/^\s*\[\s*(\d+|\*{1,2})\s*\]/)))t.push(n[1]);else if(null!==(n=o.match(/^\s*\[\s*"((?:\\"|.)*?)"\s*\]/)))t.push(n[1].replace(/\\"/g,'"'));else{if(null===(n=o.match(/^\s*\[\s*'((?:\\'|.)*?)'\s*\]/))){if(null!==(n=o.match(/^\s+$/)))break;throw _cs.exception("select","parse error: invalid character at: "+e.substr(0,s)+"<"+o.substr(0,1)+">"+o.substr(1))}t.push(n[1].replace(/\\'/g,"'"))}s+=n[0].length,o=o.substr(n[0].length)}_cs.select_cache[e]=t}return t},_cs.select_path=function(e,t){if(0===t.length){if(3===arguments.length)throw _cs.exception("select","cannot set value on empty path");return e}for(var n=0;n<t.length-1;){if("object"!=typeof e)throw _cs.exception("select","cannot further dereference: no more intermediate objects in path");e=e[t[n++]]}if("object"!=typeof e)throw _cs.exception("select","cannot further dereference: no object at end of path");var s=e[t[n]];if(3===arguments.length){var o=arguments[2];void 0===o?e instanceof Array?e.splice(parseInt(t[n],10),1):delete e[t[n]]:e[t[n]]=o}return s},_cs.clazz_or_trait=function(e,t){var n=function(){var e=arguments.callee,t=arguments;if(!(this instanceof e))return new e;return function(e,t,n,s){var o=_cs.annotation(t,"extend");null!==o&&arguments.callee(e,o,n,!1);var i=_cs.annotation(t,"mixin");if(null!==i)for(var a=0;a<i.length;a++)arguments.callee(e,i[a],n,!0);var r=_cs.annotation(t,"dynamics");if(null!==r)for(var c in r)_cs.isown(r,c)&&("null"!==_cs.istypeof(r[c])&&"function"===_cs.istypeof(r[c].clone)?e[c]=r[c].clone():e[c]=_cs.clone(r[c]));if(s){var p=_cs.annotation(t,"cons");null!==p&&("clazz"===_cs.istypeof(t)?p.apply(e,n):p.call(e))}}(this,e,t,!0),this},s=function(e){return!e.match("^(?:base|__ComponentJS_[A-Za-z]+__)$")};if(_cs.isdefined(e.extend)){_cs.extend(n,e.extend,s);var o=function(){this.constructor=n};o.prototype=e.extend.prototype,n.prototype=new o,_cs.annotation(n,"extend",e.extend)}var i=function(e,t){var n=!0;if("function"===_cs.istypeof(_cs.state_methods)){var s=_cs.state_methods(),o=[];for(var i in t)_cs.isown(t,i)&&s[i]&&(n=!1,o.push('"'+i+'"'));if(!n)throw _cs.exception("clazz_or_trait",'definition of "'+e+'" failed. You can not redefine state transition functions named '+o.join(", "))}return n};_cs.isdefined(e.statics)&&i("statics",e.statics)&&_cs.extend(n,e.statics),_cs.isdefined(e.protos)&&_cs.mixin(n.prototype,e.protos);var a=function(e,t){var n=_cs.annotation(t,"extend");return null!==n&&("clazz"===_cs.istypeof(n)&&("function"===_cs.istypeof(n[e])||"object"===_cs.istypeof(n.prototype)&&"function"===_cs.istypeof(n.prototype[e])||a(e,n)))};if(_cs.isdefined(e.mixin)){for(var r=0;r<e.mixin.length;r++){_cs.extend(n,e.mixin[r],s);for(var c in e.mixin[r].prototype)if(_cs.isown(e.mixin[r].prototype,c)&&("function"!==_cs.istypeof(n.prototype[c])||!_cs.isown(n.prototype,c))){var p;p=a(c,n)?function(){return this.base.apply(this,arguments)}:function(){},_cs.annotation(p,"name",c),n.prototype[c]=p}_cs.mixin(n.prototype,e.mixin[r].prototype,s)}_cs.annotation(n,"mixin",e.mixin)}var l=_cs.nop;_cs.isdefined(e.cons)?l=e.cons:_cs.isdefined(e.extend)&&(l=function(){this.base()}),_cs.annotation(n,"cons",l),_cs.annotation(l,"name","cons"),_cs.isdefined(e.extend)&&_cs.annotation(l,"base",_cs.annotation(e.extend,"cons")),_cs.isdefined(e.setup)&&_cs.annotation(n,"setup",e.setup),_cs.isdefined(e.dynamics)&&i("dynamics",e.dynamics)&&_cs.annotation(n,"dynamics",e.dynamics);var u=function(e,t){for(var n=_cs.annotation(e,t);null===n&&!0===_cs.annotation(e.caller,"clone");)n=_cs.annotation(e.caller,t),e=e.caller;return n},f=function(e,t,n){var s=_cs.annotation(t,"extend");if(null===s)return null;var o=!1;if("function"===_cs.istypeof(t.prototype[e])&&_cs.isown(t.prototype,e))for(var i=t.prototype[e];"function"===_cs.istypeof(i);){if(i===n){o=!0;break}i=u(i,"base")}return o?s:f(e,s,n)};if(n.prototype.base=function(){var e=u(arguments.callee.caller,"name"),t=u(arguments.callee.caller,"base"),n=f(e,this.constructor,function(e){if(null===_cs.annotation(e,"clone"))for(;!0===_cs.annotation(e.caller,"clone");)e=e.caller;return e}(arguments.callee.caller));if("function"===_cs.istypeof(t))return t.apply(this,arguments);if("string"===_cs.istypeof(e)&&"clazz"===_cs.istypeof(n)&&"function"===_cs.istypeof(n[e]))return n[e].apply(this,arguments);if("string"===_cs.istypeof(e)&&"clazz"===_cs.istypeof(n)&&"object"===_cs.istypeof(n.prototype)&&"function"===_cs.istypeof(n.prototype[e]))return n.prototype[e].apply(this,arguments);throw _cs.exception("base",'no base method found for method "'+e+'" in inheritance/mixin chain')},t){!function(e,t){if("array"===_cs.istypeof(_cs.annotation(t,"mixin")))for(var n=_cs.annotation(t,"mixin"),s=0;s<n.length;s++)arguments.callee(e,n[s]);"function"===_cs.istypeof(_cs.annotation(t,"setup"))&&_cs.annotation(t,"setup").call(e)}(n,n)}return"string"==typeof e.name&&$cs.ns(e.name,n),n},$cs.clazz=function(){var e=$cs.params("clazz",arguments,{name:{def:void 0,valid:"string"},extend:{def:void 0,valid:"clazz"},mixin:{def:void 0,valid:"[ trait* ]"},cons:{def:void 0,valid:"function"},statics:{def:void 0,valid:"object"},dynamics:{def:void 0,valid:"object"},protos:{def:void 0,valid:"{ @?: function }"}}),t=_cs.clazz_or_trait(e,!0);return _cs.annotation(t,"type","clazz"),t},$cs.trait=function(){var e=$cs.params("trait",arguments,{name:{def:void 0,valid:"string"},mixin:{def:void 0,valid:"[ trait* ]"},cons:{def:void 0,valid:"function"},setup:{def:void 0,valid:"function"},statics:{def:void 0,valid:"object"},dynamics:{def:void 0,valid:"object"},protos:{def:void 0,valid:"{ @?: function }"}}),t=_cs.clazz_or_trait(e,!1);return _cs.annotation(t,"type","trait"),t},$cs.pattern.id=$cs.trait({dynamics:{id:$cs.attribute("id",null)}}),$cs.pattern.name=$cs.trait({dynamics:{name:$cs.attribute("name","")}}),$cs.pattern.tree=$cs.trait({mixin:[$cs.pattern.name],dynamics:{parent:$cs.attribute("parent",null),children:$cs.attribute("children",[])},protos:{path:function(e){var t,n;if(void 0===e)for(t=[],n=this;null!==n;n=n.parent())t.push(n);else if(t="",null===this.parent())t=e;else for(n=this;null!==n.parent();n=n.parent())t=e+n.name()+t;return t},attach:function(e){null!==this.parent()&&this.detach();var t=e.children();t.push(this),e.children(t),this.parent(e)},detach:function(){if(null!==this.parent()){var e=this;this.parent().children(_cs.filter(this.parent().children(),function(t){return t!==e})),this.parent(null)}},walk_up:function(e,t){var n,s;for(n=0,s=this;null!==s;s=s.parent(),n++)t=e(n,s,t);return t},walk_down:function(e,t){var n=function(t,s,o){"function"==typeof e&&(o=e(t,s,o,!1));for(var i=s.children(),a=0;a<i.length;a++)o=n(t+1,i[a],o);return"function"==typeof e&&(o=e(t,s,o,!0)),o};return t=n(0,this,t)},_tree_dump:function(e){return this.walk_down(function(t,n,s,o){if(!o){for(var i=0;i<t;i++)s+="    ";s+='"'+n.name()+'"',"function"==typeof e&&(s+=": "+e(n)),s+="\n"}return s},"")}}}),$cs.pattern.config=$cs.trait({dynamics:{__config:{}},protos:{cfg:function(e,t){var n;if(0===arguments.length){n=[];for(var s in this.__config)_cs.isown(this.__config,s)&&n.push(s)}else if(1===arguments.length&&"string"==typeof e)n=this.__config[e];else if(2===arguments.length&&null!==t)n=this.__config[e],this.__config[e]=t;else{if(2!==arguments.length)throw _cs.exception("cfg","invalid arguments");n=this.__config[e],delete this.__config[e]}return n}}}),$cs.pattern.spool=$cs.trait({dynamics:{__spool:{}},protos:{spool:function(){var e=$cs.params("spool",arguments,{name:{pos:0,req:!0},ctx:{pos:1,req:!0},func:{pos:2,req:!0},args:{pos:"...",def:[]}});if(!_cs.istypeof(e.func).match(/^(string|function)$/))throw _cs.exception("spool","invalid function parameter (neither function object nor method name)");if("string"===_cs.istypeof(e.func)){if("function"!==_cs.istypeof(e.ctx[e.func]))throw _cs.exception("spool",'invalid method name: "'+e.func+'"');e.func=e.ctx[e.func]}_cs.isdefined(this.__spool[e.name])||(this.__spool[e.name]=[]),this.__spool[e.name].push(e)},spooled:function(){var e=$cs.params("spooled",arguments,{name:{pos:0,req:!0}});return _cs.isdefined(this.__spool[e.name])?this.__spool[e.name].length:0},unspool:function(){var e=$cs.params("unspool",arguments,{name:{pos:0,req:!0}}),t=this.__spool[e.name];if(!_cs.isdefined(t))throw _cs.exception("unspool",'no such spool: "'+e.name+'"');for(var n=t.length-1;n>=0;n--)t[n].func.apply(t[n].ctx,t[n].args);delete this.__spool[e.name]}}}),_cs.spool_spec_parse=function(e,t){var n={};n.comp=e,n.name=t;var s=n.name.match(/^([^:]+):(.+)$/);return null!==s&&(n.comp=$cs(e,s[1]),n.name=s[2]),n},$cs.pattern.property=$cs.trait({mixin:[$cs.pattern.tree,$cs.pattern.config],protos:{property:function(){var e=$cs.params("property",arguments,{name:{pos:0,req:!0},value:{pos:1,def:void 0},def:{def:void 0},scope:{def:void 0},bubbling:{def:!0},targeting:{def:!0},returnowner:{def:!1}});if(!e.targeting&&!e.bubbling)throw _cs.exception("property","disabling both targeting and bubbling makes no sense");var t;t=e.def;for(var n,s=[],o=this;null!==o;s.unshift(o.name()),o=o.parent())if(0!==s.length||e.targeting){if(s.length>0){for(var i=s.length-1;i>=0;i--){var a=s.slice(0,i+1).join("/");if(void 0!==(n=o.cfg("ComponentJS:property:"+e.name+"@"+a)))break}if(void 0!==n){t=e.returnowner?o:n;break}}if(void 0!==(n=o.cfg("ComponentJS:property:"+e.name))){t=e.returnowner?o:n;break}if(!e.bubbling)break}return void 0!==e.value&&(void 0!==e.scope?this.cfg("ComponentJS:property:"+e.name+"@"+e.scope,e.value):this.cfg("ComponentJS:property:"+e.name,e.value)),t}}}),$cs.pattern.spec=$cs.trait({mixin:[$cs.pattern.name],dynamics:{__spec:{}},protos:{spec:function(){var e=this.__spec;if(0===arguments.length)return e;if(1===arguments.length&&"string"==typeof arguments[0])return e[arguments[0]];for(var t=0;t<arguments.length;t++)if("string"==typeof arguments[t])e[arguments[t]]=arguments[t+1],t++;else if("object"==typeof arguments[t])for(var n in arguments[t])_cs.isown(arguments[t],n)&&(e[n]=arguments[t][n])},matches:function(e,t){if("string"==typeof e){if(this.name()!==e)return!1}else{if(!("object"==typeof e&&e instanceof RegExp))throw _cs.exception("matches","invalid name pattern");if(!this.name().match(e))return!1}var n=this.__spec;for(var s in t)if(_cs.isown(t,s)){if(!_cs.isdefined(n[s]))return!1;var o=t[s];switch(typeof n[s]){case"number":case"boolean":if(n[s]!==o)return!1;break;case"string":if(!("string"==typeof o&&n[s]===o||"object"==typeof o&&o instanceof RegExp&&!n[s].match(o)))return!1}}return!0}}}),$cs.pattern.observable=$cs.trait({dynamics:{__listener:{}},protos:{listen:function(){var e=$cs.params("listen",arguments,{name:{pos:0,req:!0},ctx:{def:this},func:{pos:1,req:!0},args:{pos:"...",def:[]},spec:{def:null}}),t=_cs.cid();return this.__listener[t]=e,t},listening:function(){var e=$cs.params("listening",arguments,{id:{pos:0,req:!0}});return void 0!==this.__listener[e.id]},unlisten:function(){var e=$cs.params("unlisten",arguments,{id:{pos:0,req:!0}});if(void 0===this.__listener[e.id])throw _cs.exception("unlisten","listener not found");var t=this.__listener[e.id];return delete this.__listener[e.id],t},notify:function(){var e=$cs.params("notify",arguments,{name:{pos:0,req:!0},args:{pos:"...",def:[]},matches:{def:function(e,t){return e.name===t.name}}});for(var t in this.__listener)if(_cs.isown(this.__listener,t)){var n=this.__listener[t];if(e.matches(e,n)){var s=_cs.concat(n.args,e.args);n.func.apply(n.ctx,s)}}}}}),$cs.pattern.event=$cs.clazz({mixin:[$cs.pattern.spec],dynamics:{target:$cs.attribute("target",null),propagation:$cs.attribute("propagation",!0),processing:$cs.attribute("processing",!0),dispatched:$cs.attribute("dispatched",!1),decline:$cs.attribute("decline",!1),state:$cs.attribute("state","targeting"),result:$cs.attribute("result",void 0),async:$cs.attribute("async",!1)}}),$cs.event=function(){var e=$cs.params("event",arguments,{name:{pos:0,req:!0},spec:{def:{}},target:{pos:1,req:!0},propagation:{pos:2,def:!0},processing:{pos:3,def:!0},dispatched:{pos:4,def:!1},decline:{pos:5,def:!1},state:{pos:6,def:"targeting"},result:{pos:7,def:void 0},async:{pos:8,def:!1}}),t=new $cs.pattern.event;return t.name(e.name),t.target(e.target),t.propagation(e.propagation),t.processing(e.processing),t.dispatched(e.dispatched),t.decline(e.decline),t.state(e.state),t.result(e.result),t.spec(e.spec),t.async(e.async),t},$cs.pattern.eventing=$cs.trait({dynamics:{__subscription:{}},protos:{subscribe:function(){var e=$cs.params("subscribe",arguments,{name:{pos:0,req:!0},spec:{def:{}},ctx:{def:this},func:{pos:1,req:!0},args:{pos:"...",def:[]},capturing:{def:!1},spreading:{def:!1},bubbling:{def:!0},noevent:{def:!1},exclusive:{def:!1},spool:{def:null}}),t=this._subscriptions(e.name.toString(),e.spec);if(1===t.length&&t[0].exclusive)throw _cs.exception("subscribe","existing exclusive subscription prevents additional one");if(e.exclusive&&t.length>0)throw _cs.exception("subscribe","non-exclusive subscription(s) prevent exclusive one");var n=_cs.cid();if(this.__subscription[n]=e,null!==e.spool){var s=_cs.spool_spec_parse(this,e.spool);s.comp.spool(s.name,this,"unsubscribe",n)}return n},unsubscribe:function(){var e=$cs.params("unsubscribe",arguments,{id:{pos:0,req:!0}});if(void 0===this.__subscription[e.id])throw _cs.exception("unsubscribe","subscription not found");delete this.__subscription[e.id]},_subscription:function(){var e=$cs.params("_subscription",arguments,{id:{pos:0,req:!0},details:{pos:1,def:!1}}),t=void 0!==this.__subscription[e.id];return e.details&&(t=t?this.__subscription[e.id]:void 0),t},_subscriptions:function(){var e=$cs.params("_subscriptions",arguments,{name:{pos:0,req:!0},spec:{pos:1,def:{}}}),t=$cs.event({name:e.name,spec:e.spec,target:_cs.nop}),n=[];for(var s in this.__subscription)if(_cs.isown(this.__subscription,s)){var o=this.__subscription[s];t.matches(o.name,o.spec)&&n.push(o)}return n},publish:function(){var e,t=this,n=$cs.params("publish",arguments,{name:{pos:0,req:!0},spec:{def:{}},async:{def:!1},capturing:{def:!0},spreading:{def:!1},bubbling:{def:!0},completed:{def:_cs.nop},resultinit:{def:void 0},resultstep:{def:function(e,t){return t}},directresult:{def:!1},noresult:{def:!1},firstonly:{def:!1},silent:{def:!1},args:{pos:"...",def:[]}}),s=!1;if(!n.capturing&&!n.spreading&&!n.bubbling){var o=!1;for(var i in this.__subscription)if(_cs.isown(this.__subscription,i)){o=!0;break}if(!o){if(n.noresult)return;if(n.directresult)return n.resultinit;s=!0}}var a=$cs.event({name:n.name,spec:n.spec,async:n.async,result:n.resultinit,target:t,propagation:!0,processing:!0,dispatched:!1});if(s)return a;n.silent||$cs.debug(1,"event: "+a.target().path("/")+": publish: name="+a.name()+" async="+a.async()+" capturing="+n.capturing+" spreading="+n.spreading+" bubbling="+n.bubbling+" directresult="+n.directresult+" noresult="+n.noresult+" firstonly="+n.firstonly);var r=function(e,t,n,s){for(var o in t.__subscription)if(_cs.isown(t.__subscription,o)){var i=t.__subscription[o];if(("capturing"===s&&i.capturing||"targeting"===s||"spreading"===s&&i.spreading||"bubbling"===s&&i.bubbling)&&e.matches(i.name,i.spec)){n.silent||$cs.debug(1,"event: "+t.path("/")+": dispatch "+e.name()+" to subscriber on "+s),e.state(s),e.decline(!1);var a=_cs.concat(i.noevent?[]:[e],i.args,n.args),r=i.func.apply(i.ctx,a);i.noevent&&_cs.isdefined(r)&&e.result(n.resultstep(e.result(),r)),e.decline()||(e.dispatched(!0),n.firstonly&&e.propagation(!1))}}},c=function(t,n,s){var o;if((s.capturing||s.bubbling)&&(o=n.path()),s.capturing)for(e=o.length-1;e>=1&&(r(t,o[e],s,"capturing"),t.propagation());e--);if(t.propagation()&&r(t,n,s,"targeting"),s.spreading&&t.propagation()){var i=function(e,n){var o=!0;if(n||(r(t,e,s,"spreading"),t.propagation()||(t.propagation(!0),o=!1)),o)for(var a=e.children(),c=0;c<a.length;c++)i(a[c],!1)};i(n,!0)}if(s.bubbling&&t.propagation())for(e=1;e<o.length&&(r(t,o[e],s,"bubbling"),t.propagation());e++);s.completed.call(n,t)};return a.async()?setTimeout(_cs.hook("ComponentJS:settimeout:func","pass",function(){c(a,t,n)}),0):c(a,t,n),n.noresult?void 0:n.directresult?a.result():a}}}),$cs.pattern.command=$cs.clazz({mixin:[$cs.pattern.observable],dynamics:{ctx:$cs.attribute("ctx",null),func:$cs.attribute("func",_cs.nop),args:$cs.attribute("args",[]),async:$cs.attribute("async",!1),enabled:$cs.attribute("enabled",!0,"boolean")},protos:{execute:function(e,t){if(this.enabled()){var n=[];return this.async()&&n.push(function(e){"function"==typeof t&&t(e)}),n=_cs.concat(n,this.args(),e),this.func().apply(this.ctx(),n)}}}}),$cs.command=function(){var e=$cs.params("command",arguments,{ctx:{def:null},func:{pos:0,req:!0},args:{pos:"...",def:[]},async:{def:!1},enabled:{def:!0},wrap:{def:!1}}),t=new $cs.pattern.command;t.ctx(e.ctx),t.func(e.func),t.args(e.args),t.async(e.async),t.enabled(e.enabled);var n=t;return e.wrap&&((n=function(){var e=_cs.concat(arguments),t=null;return arguments.callee.command.async()&&(t=e.pop()),arguments.callee.command.execute.call(arguments.callee.command,e,t)}).command=t),n},_cs.states=[{enter:null,leave:null,state:"dead",color:"#000000"}],_cs.states_clear=function(){_cs.states=_cs.slice(_cs.states,0,1)},_cs.states_add=function(e,t,n,s,o){for(var i={enter:t,leave:n,state:e,color:s},a=1;a<_cs.states.length&&(null===o||_cs.states[a].state!==o);)a++;_cs.states.splice(a,0,i)},_cs.state_methods=function(){var e,t={};for(e=0;e<_cs.states.length;e++)_cs.states[e].enter&&(t[_cs.states[e].enter]=_cs.states[e]),_cs.states[e].leave&&(t[_cs.states[e].leave]=_cs.states[e]);return t},_cs.state_name2idx=function(e){var t,n=-1;for(t=0;t<_cs.states.length;t++)if(_cs.states[t].state===e){n=t;break}return n},_cs.state_method_call=function(e,t,n){var s=!0,o=t.obj();if(null!==o&&"function"==typeof o[n]){var i={type:e,comp:t,method:n,ctx:o,func:o[n]};if(_cs.hook("ComponentJS:state-method-call","none",i),"object"===(s=i.func.call(i.ctx))&&"function"===s.then){var a=null;"enter"===e&&t.__state<_cs.states.length-1?a=_cs.states[t.__state+1].enter:"leave"===e&&t.__state>0&&(a=_cs.states[t.__state-1].leave),null!==a&&(t.guard(a,1),s=s.then(function(e){return t.guard(a,-1),e}).catch(function(e){throw t.guard(a,-1),e}))}}return s},_cs.state_requests={},_cs.state_progression=function(){setTimeout(_cs.hook("ComponentJS:settimeout:func","pass",function(){var e=[];for(var t in _cs.state_requests)if(_cs.isown(_cs.state_requests,t)){var n=_cs.state_requests[t];_cs.state_progression_single(n)&&e.push(t)}_cs.foreach(e,function(e){delete _cs.state_requests[e]}),_cs.hook("ComponentJS:state-change","none")}),0)},_cs.state_progression_single=function(e){var t=!1;return _cs.state_progression_run(e.comp,e.state),_cs.states[e.comp.__state].state===e.state&&(t=!0),t},_cs.state_progression_run=function(e,t,n){var s,o,i,a,r,c;void 0===n&&(n="upward-and-downward");var p=_cs.state_name2idx(t);if(-1===p)throw _cs.exception("state",'invalid argument "'+t+'"');if(e.__state<p)for(;e.__state<p;){if(i=_cs.states[e.__state+1].state,a=_cs.states[e.__state+1].enter,null!==e.parent()&&e.parent().state_compare(i)<0&&(_cs.state_progression_run(e.parent(),i,"upward"),e.parent().state_compare(i)<0))return void $cs.debug(1,"state: "+e.path("/")+": transition (increase) REJECTED BY PARENT COMPONENT ("+e.parent().path("/")+"): @"+_cs.states[e.__state].state+" --("+a+")--\x3e @"+_cs.states[e.__state+1].state+": SUSPENDING CURRENT TRANSITION RUN");if(_cs.isdefined(e.__state_guards[a]))return void $cs.debug(1,"state: "+e.path("/")+": transition (increase) REJECTED BY ENTER GUARD: @"+_cs.states[e.__state].state+" --("+a+")--\x3e @"+_cs.states[e.__state+1].state+": SUSPENDING CURRENT TRANSITION RUN");if(e.__state++,$cs.debug(1,"state: "+e.path("/")+": transition (increase): @"+_cs.states[e.__state-1].state+" --("+a+")--\x3e @"+_cs.states[e.__state].state),_cs.hook("ComponentJS:state-invalidate","none","states"),_cs.hook("ComponentJS:state-change","none"),!1===_cs.state_method_call("enter",e,a))return $cs.debug(1,"state: "+e.path("/")+": transition (increase) REJECTED BY ENTER METHOD: @"+_cs.states[e.__state-1].state+" --("+a+")--\x3e @"+_cs.states[e.__state].state+": SUSPENDING CURRENT TRANSITION RUN"),void e.__state--;if(e.publish({name:"ComponentJS:state:"+_cs.states[e.__state].state+":enter",noresult:!0,capturing:!1,spreading:!1,bubbling:!1,async:!0,silent:!0}),_cs.hook("ComponentJS:state-enter","none",e,_cs.states[e.__state].state),"upward-and-downward"===n||"downward"===n)for(o=e.children(),s=0;s<o.length;s++)o[s].state_compare(i)<0&&(o[s].state_auto_increase()||!0===o[s].property("ComponentJS:state-auto-increase"))&&(_cs.state_progression_run(o[s],i,"downward"),o[s].state_compare(i)<0&&(_cs.state_requests[o[s].id()]={comp:o[s],state:i},_cs.hook("ComponentJS:state-invalidate","none","requests"),_cs.hook("ComponentJS:state-change","none")))}else if(e.__state>p)for(;e.__state>p;){i=_cs.states[e.__state].state,r=_cs.states[e.__state].leave;var l=_cs.states[e.__state-1].state;for(o=e.children(),s=0;s<o.length;s++)if(o[s].state_compare(l)>0&&(_cs.state_progression_run(o[s],l,"downward"),o[s].state_compare(l)>0))return void $cs.debug(1,"state: "+e.path("/")+": transition (decrease) REJECTED BY CHILD COMPONENT ("+o[s].path("/")+"): @"+_cs.states[e.__state-1].state+" <--("+r+")-- @"+_cs.states[e.__state].state+": SUSPENDING CURRENT TRANSITION RUN");if(_cs.isdefined(e.__state_guards[r]))return void $cs.debug(1,"state: "+e.path("/")+": transition (decrease) REJECTED BY LEAVE GUARD: @"+_cs.states[e.__state-1].state+" <--("+r+")-- @"+_cs.states[e.__state].state+": SUSPENDING CURRENT TRANSITION RUN");if(e.__state--,$cs.debug(1,"state: "+e.path("/")+": transition (decrease): @"+_cs.states[e.__state].state+" <--("+r+")-- @"+_cs.states[e.__state+1].state),_cs.hook("ComponentJS:state-invalidate","none","states"),_cs.hook("ComponentJS:state-change","none"),!1===_cs.state_method_call("leave",e,r))return $cs.debug(1,"state: "+e.path("/")+": transition (decrease) REJECTED BY LEAVE METHOD: @"+_cs.states[e.__state].state+" <--("+r+")-- @"+_cs.states[e.__state+1].state+": SUSPENDING CURRENT TRANSITION RUN"),void e.__state++;(c=e.spooled(i))>0&&($cs.debug(1,"state: "+e.path("/")+": auto-unspooling "+c+" operation(s)"),e.unspool(i)),e.publish({name:"ComponentJS:state:"+_cs.states[e.__state+1].state+":leave",noresult:!0,capturing:!1,spreading:!1,bubbling:!1,async:!0,silent:!0}),_cs.hook("ComponentJS:state-leave","none",e,_cs.states[e.__state+1].state),"upward-and-downward"!==n&&"upward"!==n||null!==e.parent()&&e.parent().state_compare(l)>0&&(e.parent().state_auto_decrease()||!0===e.parent().property("ComponentJS:state-auto-decrease"))&&(_cs.state_progression_run(e.parent(),l,"upward"),e.parent().state_compare(l)>0&&(_cs.state_requests[e.parent().id()]={comp:e.parent(),state:l},_cs.hook("ComponentJS:state-invalidate","none","requests"),_cs.hook("ComponentJS:state-change","none")))}},_cs.state_request_clear=function(e){e&&_cs.state_requests[e]&&delete _cs.state_requests[e]},_cs.guard_clear=function(e){e&&(e.__state_guards={})},$cs.pattern.state=$cs.trait({mixin:[$cs.pattern.tree],dynamics:{__state:0,__state_guards:{},state_auto_increase:$cs.attribute("state_auto_increase",!1),state_auto_decrease:$cs.attribute("state_auto_decrease",!1)},protos:{state:function(){var e=_cs.states[this.__state].state;if(0===arguments.length)return e;var t=$cs.params("state",arguments,{state:{pos:0,req:!0,valid:function(e){return-1!==_cs.state_name2idx(e)}},func:{pos:1,def:void 0},min:{def:void 0},max:{def:void 0},sync:{def:!1}}),n=this.__state,s=_cs.state_name2idx(t.state);if(!0===t.min&&!t.max&&s>n||!t.min&&!0===t.max&&s<n||!0===t.min&&!0===t.max&&s!==n||!t.min&&!t.max&&s!==n){var o=!0,i=this.id(),a={comp:this,state:t.state};"function"==typeof t.func&&_cs.states.length>1&&this.await({state:t.state,direction:s>n?"upward":"downward",func:t.func,spool:_cs.states[1].state}),t.sync&&(_cs.state_progression_single(a)&&(o=!1),_cs.state_requests[i]&&delete _cs.state_requests[i]),o&&(_cs.state_requests[i]=a,_cs.hook("ComponentJS:state-invalidate","none","requests"),_cs.state_progression())}else"function"==typeof t.func&&t.func.call(this,t.state);return e},state_compare:function(){var e=$cs.params("state",arguments,{state:{pos:0,req:!0,valid:function(e){return-1!==_cs.state_name2idx(e)}}}),t=_cs.state_name2idx(e.state);return this.__state-t},guard:function(){var e,t=$cs.params("guard",arguments,{method:{pos:0,valid:"string",req:!0},level:{pos:1,valid:"number",req:!0}}),n=!1;for(e=0;e<_cs.states.length;e++)if(_cs.states[e].enter===t.method||_cs.states[e].leave===t.method){n=!0;break}if(!n)throw _cs.exception("guard",'no such declared enter/leave method: "'+t.method+'"');_cs.isdefined(this.__state_guards[t.method])||(this.__state_guards[t.method]=0);var s=!1;if(t.level>0)this.__state_guards[t.method]+=t.level;else if(t.level<0){if(this.__state_guards[t.method]<-t.level)throw _cs.exception("guard","guard level decrease request too large");this.__state_guards[t.method]+=t.level,0===this.__state_guards[t.method]&&(s=!0)}else this.__state_guards[t.method]=0,s=!0;s&&(delete this.__state_guards[t.method],_cs.state_progression())},await:function(){var e,t=$cs.params("await",arguments,{state:{pos:0,req:!0},func:{pos:1,req:!0},direction:{pos:2,def:"upward",valid:/^upward|downward$/},spool:{def:null}}),n=!1;for(e=0;e<_cs.states.length;e++)if(_cs.states[e].state===t.state){n=!0;break}if(!n)throw _cs.exception("await",'no such declared state: "'+t.state+'"');var s,o=this,i=t.state;if("downward"===t.direction){var a=_cs.state_name2idx(t.state);if(a+1===_cs.states.length)throw _cs.exception("await",'can not await last state: "'+t.state+'" to occur from direction "'+t.direction+'"');i=_cs.states[a+1].state}if(s=this.subscribe({name:"ComponentJS:state:"+i+":"+("upward"===t.direction?"enter":"leave"),ctx:this,func:function(){t.func.call(o,t.state),s&&o.unawait(s)},noevent:!0,capturing:!1,spreading:!1,bubbling:!1}),null!==t.spool){var r=_cs.spool_spec_parse(this,t.spool);r.comp.spool(r.name,this,"unawait",s)}return s},unawait:function(){var e=$cs.params("unawait",arguments,{id:{pos:0,req:!0}});this._subscription(e.id)&&this.unsubscribe(e.id)}}}),$cs.pattern.service=$cs.trait({mixin:[$cs.pattern.eventing],protos:{register:function(){var e=$cs.params("register",arguments,{name:{pos:0,req:!0},ctx:{def:this},func:{pos:1,req:!0},args:{pos:"...",def:[]},spool:{def:null},capturing:{def:!1},spreading:{def:!1},bubbling:{def:!0}}),t=$cs.command({ctx:e.ctx,func:e.func,args:e.args,wrap:!0});t.command.listen({name:"attribute:set:enabled",args:[this,e.name],func:function(e,t,n,s){e.publish({name:"ComponentJS:service:"+t+":callable",args:[n,s],capturing:!1,spreading:!1,bubbling:!1,async:!0,noresult:!0})}});var n=this.subscribe({name:"ComponentJS:service:"+e.name,ctx:e.ctx,func:t,noevent:!0,capturing:e.capturing,spreading:e.spreading,bubbling:e.bubbling,exclusive:!0});if(null!==e.spool){var s=_cs.spool_spec_parse(this,e.spool);s.comp.spool(s.name,this,"unregister",n)}return n},unregister:function(){var e=$cs.params("unregister",arguments,{id:{pos:0,req:!0}});this.unsubscribe(e.id)},callable:function(){var e=$cs.params("callable",arguments,{name:{pos:0,req:!0},value:{pos:1,def:void 0}}),t=this._subscriptions(e.name);if(1===t.length){return t[0].func().command.enabled(e.value)}},call:function(){var e=$cs.params("call",arguments,{name:{pos:0,req:!0},args:{pos:"...",def:[]},capturing:{def:!1},spreading:{def:!1},bubbling:{def:!0}}),t=this.publish({name:"ComponentJS:service:"+e.name,args:e.args,capturing:e.capturing,spreading:e.spreading,bubbling:e.bubbling,firstonly:!0,async:!1});if(!t.dispatched())throw _cs.exception("call",'no such registered service found: "'+e.name+'"');return t.result()}}}),$cs.pattern.backing=$cs.trait({dynamics:{__obj:null},protos:{obj:function(e){if(void 0===e)return this.__obj;if("object"!=typeof e)throw _cs.exception("obj","invalid argument");return null!==e?(_cs.annotation(e,"comp",this),this.__obj=e):(null!==this.__obj&&_cs.annotation(this.__obj,"comp",null),this.__obj=null),this},access:function(e,t){if(void 0===e)throw _cs.exception("access","no attribute name given");var n=this.obj();if(null===n)throw _cs.exception("access","still no object attached");if(void 0===n[e])throw _cs.exception("access",'invalid attribute "'+e+'"');var s=n[e];return void 0!==t&&(n[e]=t),s},invoke:function(e){if(void 0===e)throw _cs.exception("invoke","no method name given");var t=this.obj();if(null===t)throw _cs.exception("invoke","still no object attached");if(void 0===t[e])throw _cs.exception("invoke",'invalid method "'+e+'"');if("function"!==_cs.istypeof(t[e]))throw _cs.exception("invoke",'anything named "'+e+'" existing, but not a function');var n=_cs.slice(arguments,1);return t[e].apply(t,n)}}}),$cs.pattern.socket=$cs.trait({mixin:[$cs.pattern.tree,$cs.pattern.property],dynamics:{__sockets:{},__plugs:{}},protos:{socket:function(){var e=$cs.params("socket",arguments,{name:{def:"default"},scope:{def:null},ctx:{pos:0,req:!0},plug:{pos:1,req:!0},unplug:{pos:2,req:!0},spool:{def:null}});if("string"===_cs.istypeof(e.plug)&&"function"!==_cs.istypeof(e.ctx[e.plug]))throw _cs.exception("socket",'no plug method named "'+e.plug+'" found on context object');if("string"!==_cs.istypeof(e.plug)&&"function"!==_cs.istypeof(e.plug))throw _cs.exception("socket","plug operation neither method name nor function");if("string"===_cs.istypeof(e.unplug)&&"function"!==_cs.istypeof(e.ctx[e.unplug]))throw _cs.exception("socket",'no unplug method named "'+e.unplug+'" found on context object');if("string"!==_cs.istypeof(e.unplug)&&"function"!==_cs.istypeof(e.unplug))throw _cs.exception("socket","unplug operation neither method name nor function");var t="ComponentJS:socket:"+e.name;null!==e.scope&&(t+="@"+e.scope),$cs(this).property(t,e);var n=_cs.cid();if(this.__sockets[n]=t,null!==e.spool){var s=_cs.spool_spec_parse(this,e.spool);s.comp.spool(s.name,this,"unsocket",n)}return n},unsocket:function(){var e=$cs.params("unsocket",arguments,{id:{pos:0,req:!0}});if(void 0===this.__sockets[e.id])throw _cs.exception("unsocket","socket not found");var t=this.__sockets[e.id];$cs(this).property(t,null),delete this.__sockets[e.id]},link:function(){var e=$cs.params("link",arguments,{name:{def:"default"},scope:{def:null},target:{pos:0,req:!0},socket:{pos:1,req:!0},spool:{def:null}});return this.socket({name:e.name,scope:e.scope,spool:e.spool,ctx:{},plug:function(t){var n=_cs.annotation(t,"link");if(null!==n)throw _cs.exception("link:plug: cannot plug, you have to unplug first");n=$cs(e.target).plug({name:e.socket,object:t,targeting:!0}),_cs.annotation(t,"link",n)},unplug:function(t){var n=_cs.annotation(t,"link");if(null===n)throw _cs.exception("link:unplug: cannot unplug, you have to plug first");$cs(e.target).unplug({id:n,targeting:!0}),_cs.annotation(t,"link",null)}})},unlink:function(){var e=$cs.params("unlink",arguments,{id:{pos:0,req:!0}});return this.unsocket(e.id)},plug:function(){var e=$cs.params("plug",arguments,{name:{def:"default"},object:{pos:0,req:!0},spool:{def:null},targeting:{def:!1}}),t=_cs.cid();if(this.__plugs[t]=e,_cs.plugger("plug",this,e.name,e.object,e.targeting),null!==e.spool){var n=_cs.spool_spec_parse(this,e.spool);n.comp.spool(n.name,this,"unplug",t)}return t},unplug:function(){var e=$cs.params("unplug",arguments,{id:{pos:0,req:!0},targeting:{def:!1}});if(void 0===this.__plugs[e.id])throw _cs.exception("unplug","plugging not found");var t=this.__plugs[e.id].name,n=this.__plugs[e.id].object;_cs.plugger("unplug",this,t,n,e.targeting),delete this.__plugs[e.id]}}}),_cs.plugger=function(e,t,n,s,o){var i="ComponentJS:socket:"+n,a=t.property({name:i,targeting:o});if(!_cs.isdefined(a))throw _cs.exception(e,"no socket found on parent component(s)");var r=t.property({name:i,targeting:o,returnowner:!0});if($cs.debug(1,"socket: "+r.path("/")+": "+n+" <--("+e+")-- "+t.path("/")),"string"===_cs.istypeof(a[e]))a.ctx[a[e]].call(a.ctx,s,t);else{if("function"!==_cs.istypeof(a[e]))throw _cs.exception(e,'failed to perform "'+e+'" operation');a[e].call(a.ctx,s,t)}},$cs.mark=function(e,t){var n=_cs.annotation(e,"marker");null===n&&(n={}),n[t]=!0,_cs.annotation(e,"marker",n)},$cs.marked=function(e,t){var n=_cs.annotation(e,"marker");return null===n&&(n={}),!0===n[t]},$cs.pattern.marker=$cs.trait({protos:{mark:function(e){$cs.mark(this.obj(),e)},marked:function(e){return $cs.marked(this.obj(),e)}}}),$cs.marker={service:$cs.trait({cons:function(){$cs.mark(this,"service")}}),controller:$cs.trait({cons:function(){$cs.mark(this,"controller")}}),model:$cs.trait({cons:function(){$cs.mark(this,"model")}}),view:$cs.trait({cons:function(){$cs.mark(this,"view")}})},_cs.store_load=function(e){null===e.__store&&(_cs.hook("ComponentJS:store-load","none",e),null!==e.__store&&"object"==typeof e.__store||(e.__store={}))},_cs.store_save=function(e){null!==e.__store&&_cs.hook("ComponentJS:store-save","none",e)},$cs.pattern.store=$cs.trait({dynamics:{__store:null},protos:{store:function(){var e,t;if(0===arguments.length){_cs.store_load(this);var n=[];for(e in this.__store)n.push(e);return n}if(1===arguments.length&&null===arguments[0])return this.__store={},_cs.store_save(this),null;if(1===arguments.length&&"string"==typeof arguments[0])return _cs.store_load(this),e=arguments[0],void 0===this.__store[e]?null:this.__store[e];if(2===arguments.length&&null===arguments[1])return _cs.store_load(this),e=arguments[0],delete this.__store[e],_cs.store_save(this),null;if(2===arguments.length)return _cs.store_load(this),e=arguments[0],t=arguments[1],this.__store[e]=t,_cs.store_save(this),t;throw _cs.exception("store","invalid argument(s)")}}}),$cs.pattern.model=$cs.trait({protos:{model:function(){var e={spec:$cs.params("model",arguments,{spec:{pos:0,req:!0,valid:"{ @: { value?: any, valid?: (string|function|RegExp), autoreset?: boolean, store?: boolean} }"}}).spec,data:{}};_cs.foreach(_cs.keysof(e.spec),function(t){var n=e.spec[t];if(void 0===n.value&&(n.value=""),void 0===n.valid&&(n.valid="string"),void 0===n.autoreset&&(n.autoreset=!1),void 0===n.store&&(n.store=!1),!$cs.validate(n.value,n.valid))throw _cs.exception("model",'model field "'+t+'" has default value '+_cs.json(n.value)+', which does not validate against validation specification "'+n.valid+'"');e.data[t]=n.value});var t=this.store("model");null!==t&&_cs.foreach(_cs.keysof(e.spec),function(n){e.spec[n].store&&_cs.isdefined(t[n])&&(e.data[n]=t[n])});var n=this.property({name:"ComponentJS:model",bubbling:!1});if(_cs.isdefined(n)){var s={spec:{},data:{}};_cs.extend(s.spec,n.spec),_cs.extend(s.data,n.data),_cs.extend(s.spec,e.spec),_cs.extend(s.data,e.data),e=s}t={};var o=!1;_cs.foreach(_cs.keysof(e.spec),function(n){e.spec[n].store&&(t[n]=e.data[n],o=!0)}),o&&this.store("model",t),this.property("ComponentJS:model",e)},value:function(){var e=$cs.params("value",arguments,{name:{pos:0,req:!0,valid:"string"},value:{pos:1,def:void 0,valid:"any"},force:{pos:2,def:!1,valid:"boolean"},injected:{def:!1,valid:"boolean"},op:{def:[],valid:"(string|[string?]|[string,number,number])"},returnowner:{def:!1,valid:"boolean"}});if("string"==typeof e.op&&(e.op=[e.op]),0===e.op.length)e.op=_cs.isdefined(e.value)?["set"]:["get"];else if(!e.op[0].match(/^(?:get|set|splice|delete|push|pop|shift|unshift)$/))throw _cs.exception("value",'invalid operation "'+e.op[0]+'"');if("splice"===e.op[0]&&(3!==e.op.length||"number"!=typeof e.op[1]||"number"!=typeof e.op[2]))throw _cs.exception("value",'invalid arguments for operation "splice"');for(var t=_cs.select_parse(e.name),n=t.join("."),s=null,o=null,i=this;null!==i;){if(s=i.property({name:"ComponentJS:model",returnowner:!0}),!_cs.isdefined(s))throw _cs.exception("value",'no model found containing value "'+t[0]+'"');if(o=s.property("ComponentJS:model"),_cs.isdefined(o.spec[t[0]]))break;i=s.parent()}if(null===i)throw _cs.exception("value",'no model found containing value "'+t[0]+'"');var a,r=e.value;switch(e.op[0]){case"unshift":e.op=["splice",0,0];break;case"shift":e.op=["splice",0,1],r=void 0;break;case"push":a=$cs.select(o.data,t),e.op=["splice",a.length,0];break;case"pop":a=$cs.select(o.data,t),e.op=["splice",a.length-1,1],r=void 0}var c,p,l=$cs.select(o.data,t);if("splice"===e.op[0]?l=e.op[2]>0?$cs.select(l,""+e.op[1]):void 0:"get"===e.op[0]&&s.property({name:"ComponentJS:model:subscribers:get",def:0,bubbling:!1})>0&&(c=s.publish({name:"ComponentJS:model:"+n+":"+e.op[0],args:[l,l,e.op,n],capturing:!1,spreading:!1,bubbling:!1,async:!1})).processing()&&void 0!==(p=c.result())&&(l=p),"set"===e.op[0]&&(e.force||l!==r)||"delete"===e.op[0]||"splice"===e.op[0]){if("set"===e.op[0]||"splice"===e.op[0]&&void 0!==r){var u="splice"===e.op[0]?t.slice(1).concat(["0"]):t.slice(1);if(!_cs.validate_at(r,o.spec[t[0]].valid,u))throw _cs.exception("value",'model field "'+e.name+'" receives new value '+_cs.json(r)+', which does not validate against "'+o.spec[t[0]].valid+'"'+(u.length>0?' at sub-path "'+u.join(".")+'"':""))}var f=!0;if(s.property({name:"ComponentJS:model:subscribers:"+e.op[0],def:0,bubbling:!1})>0)if((c=s.publish({name:"ComponentJS:model:"+n+":"+e.op[0],args:[r,l,e.op,n],capturing:!1,spreading:!1,bubbling:!1,async:!1})).processing())void 0!==(p=c.result())&&(r=p);else{if(e.injected)throw _cs.exception("value",'model field "'+e.name+'" receives (again) value '+_cs.json(r)+", which is rejected by observers, but the value was indicated to be already injected by third-parties (so it technically no longer can be rejected)");f=!1}if(f&&!o.spec[t[0]].autoreset){if("set"===e.op[0])$cs.select(o.data,t,r);else if("splice"===e.op[0]){if(!((a=$cs.select(o.data,t))instanceof Array))throw new _cs.exception("value","cannot splice: target object is not of Array type");void 0!==r?a.splice(e.op[1],e.op[2],r):a.splice(e.op[1],e.op[2])}else if("delete"===e.op[0]){if(t.length<2)throw new _cs.exception("value","cannot delete model root or top-level model entry");a=$cs.select(o.data,t.slice(0,t.length-1));var _=t[t.length-1];if(a instanceof Array)a.splice(parseInt(_,10),1);else{if("object"!=typeof a)throw new _cs.exception("value","cannot delete: target object is neither Array nor Object type");delete a[_]}}if(o.spec[t[0]].store){var d=s.store("model");d[t[0]]=o.data[t[0]],s.store("model",d)}s.property({name:"ComponentJS:model:subscribers:changed",def:0,bubbling:!1})>0&&s.publish({name:"ComponentJS:model:"+n+":changed",args:[r,l,e.op,n],noresult:!0,capturing:!1,spreading:!1,bubbling:!1,async:!0})}}return e.returnowner?s:l},touch:function(){var e=$cs.params("touch",arguments,{name:{pos:0,req:!0,valid:"string"}});this.value({name:e.name,value:this.value(e.name),injected:!0,force:!0})},observe:function(){for(var e=$cs.params("observe",arguments,{name:{pos:0,req:!0,valid:"string"},func:{pos:1,req:!0,valid:"function"},touch:{def:!1,valid:"boolean"},boot:{def:!1,valid:"boolean"},op:{def:"set",valid:/^(?:get|set|changed|splice|delete)$/},spool:{def:null,valid:"(null|string)"},noevent:{def:!1,valid:"boolean"}}),t=_cs.select_parse(e.name),n=null,s=null,o=this;null!==o;){if(n=o.property({name:"ComponentJS:model",returnowner:!0}),!_cs.isdefined(n))throw _cs.exception("observe",'no model found containing value "'+t[0]+'"');if(s=n.property("ComponentJS:model"),_cs.isdefined(s.spec[t[0]]))break;o=n.parent()}if(null===o)throw _cs.exception("observe",'no model found containing value "'+t[0]+'"');var i=t.join(".").replace(/\./g,"\\.").replace(/\*\*/g,".+?").replace(/\*/g,"[^.]+");i+="(?:\\.[^.]+)*";var a=n.subscribe({name:new RegExp("ComponentJS:model:"+i+":"+e.op),capturing:!1,spreading:!1,bubbling:!1,noevent:e.noevent,func:e.func}),r="ComponentJS:model:subscribers:"+e.op,c=n.property({name:r,def:0});if(c+=1,n.property({name:r,value:c}),null!==e.spool){var p=_cs.spool_spec_parse(this,e.spool);p.comp.spool(p.name,this,"unobserve",a)}if(e.touch)this.touch(e.name);else if(e.boot){var l=this.value(e.name),u=[l,l,e.op,t.join(".")];e.noevent||u.unshift($cs.event({name:e.name,spec:{},async:!1,result:void 0,target:this,propagation:!0,processing:!0,dispatched:!1})),e.func.apply(this,u)}return a},unobserve:function(){for(var e,t=$cs.params("unobserve",arguments,{id:{pos:0,req:!0,valid:"string"}}),n=null,s=this;null!==s;){if(n=s.property({name:"ComponentJS:model",returnowner:!0}),!_cs.isdefined(n))throw _cs.exception("unobserve","no model subscription found");if(void 0!==(e=n._subscription(t.id,!0)))break;s=n.parent()}if(null===s)throw _cs.exception("unobserve","no model subscription found");n.unsubscribe(t.id);var o="ComponentJS:model:subscribers:"+e.op,i=n.property({name:o,def:0});i=i>0?i-1:null,n.property({name:o,value:i})}}}),_cs.comp=null,_cs.none=null,_cs.root=null,_cs.comp_mixins=[$cs.pattern.id,$cs.pattern.name,$cs.pattern.tree,$cs.pattern.config,$cs.pattern.spool,$cs.pattern.state,$cs.pattern.service,$cs.pattern.eventing,$cs.pattern.property,$cs.pattern.backing,$cs.pattern.socket,$cs.pattern.model,$cs.pattern.store,$cs.pattern.marker],_cs.comp_cons=function(e,t,n){_cs.annotation(this,"type","component"),"string"!==_cs.istypeof(e)&&(e="<unknown>"),this.name(e),this.parent("object"===_cs.istypeof(t)?t:null),this.children("array"===_cs.istypeof(n)?n:[])},_cs.comp_protos={create:function(){return $cs.create.apply(this,_cs.concat([this],arguments))},destroy:function(){return $cs.destroy.apply(this,_cs.concat([this],arguments))},exists:function(){return"<none>"!==this.name()}},_cs.bootstrapped=!1,$cs.bootstrap=function(){if(_cs.bootstrapped)throw _cs.exception("bootstrap","library already bootstrapped");_cs.hook("ComponentJS:bootstrap:comp:mixin","none",_cs.comp_mixins),_cs.hook("ComponentJS:bootstrap:comp:protos","none",_cs.comp_protos),_cs.comp=$cs.clazz({mixin:_cs.comp_mixins,cons:_cs.comp_cons,protos:_cs.comp_protos}),_cs.root=new _cs.comp("<root>",null,[]),_cs.none=new _cs.comp("<none>",null,[]);_cs.foreach(["call","callable","create","destroy","guard","hook","invoke","latch","link","model","observe","plug","property","publish","register","registration","socket","spool","spooled","state","state_compare","store","subscribe","subscription","touch","unlatch","unobserve","unplug","unregister","unspool","unsubscribe","value"],function(e){_cs.none[e]=function(){throw _cs.exception(e,'no such component (you are calling method "'+e+'" on component "<none>")')}}),_cs.hook("ComponentJS:bootstrap","none"),_cs.bootstrapped=!0},$cs.shutdown=function(){if(!_cs.bootstrapped)throw _cs.exception("shutdown","library still not bootstrapped");_cs.hook("ComponentJS:shutdown","none"),_cs.foreach(_cs.root.children(),function(e){e.destroy()}),_cs.root.state({state:"dead",sync:!0}),_cs.none=null,_cs.root=null,_cs.comp=null,_cs.bootstrapped=!1},_cs.lookup=function(e,t){if(1===arguments.length&&("string"===_cs.istypeof(arguments[0])?(t=e,e=_cs.root):t=""),"string"!=typeof t)return _cs.none;if("<root>"===t)return _cs.root;if("<none>"===t)return _cs.none;var n;if("/"===t.substr(0,1))n=_cs.root,t=t.substring(1);else{var s=_cs.istypeof(e),o=_cs.annotation(e,"comp");if("component"!==s&&null!==o)n=o;else{if("component"!==s)throw _cs.exception("lookup",'invalid base component (type is "'+s+'")');n=e}}if(""!==t){var i=[];if(_cs.lookup_step(i,n,t.split("/"),0),0===i.length)n=_cs.none;else if(1===i.length)n=i[0];else{var a={};if(1!==(i=_cs.filter(i,function(e){var t=e.id(),n=void 0===a[t];return a[t]=!0,n})).length){for(var r="",c=0;c<i.length;c++)r+=" "+i[c].path("/");throw _cs.exception("lookup",'ambiguous component path "'+t+'" at '+n.path("/")+": expected only 1 component, but found "+i.length+" components:"+r)}n=i[0]}}return n},_cs.lookup_step=function(e,t,n,s){var o,i,a;if(s>=n.length)e.push(t);else if("."===n[s])_cs.lookup_step(e,t,n,s+1);else if(".."===n[s])null!==t.parent()&&_cs.lookup_step(e,t.parent(),n,s+1);else if("*"===n[s])for(i=t.children(),o=0;o<i.length;o++)_cs.lookup_step(e,i[o],n,s+1);else if(""===n[s])for(a=t.walk_down(function(e,t,n,s){return s||n.push(t),n},[]),o=0;o<a.length;o++)_cs.lookup_step(e,a[o],n,s+1);else for(i=t.children(),o=0;o<i.length;o++)if(i[o].name()===n[s]){_cs.lookup_step(e,i[o],n,s+1);break}},$cs.create=function(){if(!_cs.bootstrapped){var e='ComponentJS: WARNING: component system still not bootstrapped (please call "bootstrap" method before first "create" method call!)';"function"==typeof alert?alert(e):"undefined"!=typeof console&&"function"==typeof console.log&&console.log(e),$cs.bootstrap()}if(arguments.length<2)throw _cs.exception("create","invalid number of arguments");var t=0,n=null,s=null,o=[];if("string"===_cs.istypeof(arguments[t])){if("/"!==arguments[t].substr(0,1))throw _cs.exception("create",'either base component has to be given or the tree specification has to start with the root component ("/")');n=_cs.root}else if(s=arguments[t++],"component"!==_cs.istypeof(s)&&null===(s=_cs.annotation(s,"comp")))throw _cs.exception("create","invalid base argument (not an object attached to a component)");for(var i,a=[],r=arguments[t++];""!==r&&null!==(i=r.match(/^\s*([^\/{},]+|[\/{},])/));)a.push(i[1]),r=r.substr(i[1].length);for(var c=function(e,t){for(var n="",s=0;s<t&&s<e.length;s++)n+=e[s];if(s<e.length)for(n+="<",n+=e[s++],n+=">";s<e.length;s++)n+=e[s];return n},p=0;p<a.length;p++)if("/"===a[p]){if(null===n)throw _cs.exception("create","no parent component for step-down at "+c(a,p));s=n}else if("{"===a[p])o.push(s);else if(","===a[p]){if(0===o.length)throw _cs.exception("create","no open brace section for parallelism at "+c(a,p));s=o[o.length-1]}else if("}"===a[p]){if(0===o.length)throw _cs.exception("create","no more open brace section for closing at "+c(a,p));s=o.pop(),n=null}else{if(null===s)throw _cs.exception("create","no base component at "+c(a,p));n=_cs.create_single(s,a[p],arguments[t++])}if(o.length>0)throw _cs.exception("create","still open brace sections at end of tree specification");return n},_cs.create_single=function(e,t,n){if("string"!=typeof t)throw _cs.exception("create","invalid path argument (not a string)");var s=t.match(/^(.*?)\/?([^\/]+)$/);if(!s[0])throw _cs.exception("create",'invalid path "'+t+'"');var o=s[1],i=s[2],a=_cs.cid();i=i.replace(/\{id\}/g,a);var r=_cs.lookup(e,o);if(r===_cs.none)throw _cs.exception("create",'parent component path "'+o+'" not already existing (please create first)');var c=_cs.lookup(r,i);if(c!==_cs.none)throw _cs.exception("create",'leaf component path "'+i+'" already existing (please destroy first)');var p=null;switch(_cs.istypeof(n)){case"clazz":case"trait":case"function":p=new n;break;case"object":p=n;break;case"null":break;default:throw _cs.exception("create","invalid class argument")}if((c=new _cs.comp(i)).id(a),c.attach(r),c.obj(p),$cs.debug(1,"component: "+c.path("/")+": created component ["+c.id()+"]"),_cs.hook("ComponentJS:comp-created","none",c),_cs.states.length<=1)throw _cs.exception("create","no user-defined component states");return c.state({state:_cs.states[1].state,sync:!0}),_cs.hook("ComponentJS:state-invalidate","none","components"),_cs.hook("ComponentJS:state-change","none"),c},$cs.destroy=function(){if(1!==arguments.length&&2!==arguments.length)throw _cs.exception("destroy","invalid number of arguments");var e=_cs.lookup.apply(this,arguments);if(e===_cs.none)throw _cs.exception("destroy","no such component found to destroy");if(e===_cs.root)throw _cs.exception("destroy","root component cannot be destroyed");var t=e.path("/"),n=e.id();_cs.foreach(e.children(),function(e){e.destroy()}),e.state({state:"dead",sync:!0}),_cs.hook("ComponentJS:comp-destroyed","none",e),e.detach(),_cs.state_request_clear(n),_cs.guard_clear(e),e.obj(null),$cs.debug(1,"component: "+t+": destroyed component ["+n+"]"),_cs.hook("ComponentJS:state-invalidate","none","components"),_cs.hook("ComponentJS:state-change","none")},$cs.transition=function(){if(1!==arguments.length||null!==arguments[0]){var e=$cs.params("transition",arguments,{target:{pos:0,req:!0},enter:{pos:1,req:!0},leave:{pos:2,req:!0},color:{pos:3,def:"#000000"},source:{def:null}});_cs.states_add(e.target,e.enter,e.leave,e.color,e.source)}else _cs.states_clear()},$cs.transition("created","create","destroy","#cc3333"),$cs.transition("configured","setup","teardown","#eabc43"),$cs.transition("prepared","prepare","cleanup","#f2ec00"),$cs.transition("materialized","render","release","#6699cc"),$cs.transition("visible","show","hide","#669933"),$cs.transition("enabled","enable","disable","#336600"),"object"==typeof MODULE&&void 0!==MODULE.exports&&void 0===GLOBAL.ComponentJS_export||void 0!==GLOBAL.ComponentJS_export&&"CommonJS"===GLOBAL.ComponentJS_export?MODULE.exports=$cs:"function"==typeof DEFINE&&"object"==typeof DEFINE.amd&&void 0===GLOBAL.ComponentJS_export||void 0!==GLOBAL.ComponentJS_export&&"AMD"===GLOBAL.ComponentJS_export?DEFINE("ComponentJS",function(){return $cs}):$cs.symbol("ComponentJS"),_cs.plugins={},$cs.plugin=function(e,t){if(0===arguments.length){var n=[];for(e in _cs.plugins)_cs.isown(_cs.plugins,e)&&n.push(e);return n}if(1===arguments.length){if("string"!=typeof e)throw _cs.exception("plugin","invalid plugin name parameter");return void 0!==_cs.plugins[e]}if(2!==arguments.length)throw _cs.exception("plugin","invalid number of parameters");if("string"!=typeof e)throw _cs.exception("plugin","invalid plugin name parameter");if(void 0!==_cs.plugins[e])throw _cs.exception("plugin",'plugin named "'+e+'" already registered');t.call(this,_cs,$cs,GLOBAL),_cs.plugins[e]=!0}}("undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0!==this?this:{},"object"==typeof module?module:void 0,"function"==typeof define?define:void 0);