(function(){"use strict";u8.Base.ObservableObject=function(r){$.extend(this,r);this._pathTools=u8.services.reflection.propertyPathTools;this.bind()};u8.Base.ObservableObject.makeClass({name:"ObservableObject",events:["PropertyChange"]});$.extend(u8.Base.ObservableObject.prototype,{setValue:function(r,e){try{var a=new Function("o","v","o.data."+r+" = v;");a(this,e);this.raise("PropertyChange",{path:r,value:e,reason:"set"})}catch(e){u8.log.debug("ObservableObject.setValue(...) failed for path '"+r+"'")}},getValue:function(r){try{var e=new Function("o","v","return o.data."+r+";");return e(this)}catch(e){u8.log.debug("ObservableObject.getValue(...) failed for path '"+r+"'")}},add:function(r,e){var a=this.getValue(r);if(!a){$error("Adding a value failed. The array does not exist")}a.push(e);var t={reason:"add",path:this._pathTools.buildArrayPath(r,a.length-1),value:e};this.raise("PropertyChange",t)},insert:function(r,e){var a=this._pathTools.parseArrayIndex(r);if(typeof a=="undefined"){$error("Inserting is only valid for array paths.")}var t=this._pathTools.stripArrayIndex(r);var o=this.getValue(t);o.splice(a,0,e);var s={reason:"insert",path:r,fromTo:{}};for(var i=a;i<o.length-1;i++){s.fromTo[this._pathTools.buildArrayPath(t,i)]=this._pathTools.buildArrayPath(t,i+1)}this.raise("PropertyChange",s)},remove:function(r,e){var a=this._pathTools;if(a.isArrayPath(r)){var t=a.parseArrayIndex(r);if(typeof t=="undefined"){$error("Removal is only valid for array paths.")}var o=a.stripArrayIndex(r);var s=this.getValue(o);s.splice(t,1);var i={reason:"remove",path:r,fromTo:{}};for(var h=t+1;h<=s.length;h++){i.fromTo[a.buildArrayPath(o,h)]=a.buildArrayPath(o,h-1)}this.raise("PropertyChange",i)}else{var n=a.getMemberPath(r);var l=a.getParentPath(r);e=this.getValue(l);if(e&&typeof e=="object"&&e.hasOwnProperty(n)){delete e[n];i={reason:"remove",path:r,fromTo:{}};this.raise("PropertyChange",i)}}},move:function(r,e){var a=this._pathTools;var t=a.parseArrayIndex(r);if(t==e){return}var o=a.stripArrayIndex(r);var s=this.getValue(o);var i=s.splice(t,1);var h=e;s.splice(h,0,i[0]);var n={reason:"move",path:o,fromTo:{}};n.fromTo[a.buildArrayPath(o,t)]=a.buildArrayPath(o,e);if(t<=e){for(var l=t+1;l<=e;l++){n.fromTo[a.buildArrayPath(o,l)]=a.buildArrayPath(o,l-1)}}else{for(l=e;l<t;l++){n.fromTo[a.buildArrayPath(o,l)]=a.buildArrayPath(o,l+1)}}this.raise("PropertyChange",n)},dispose:function(){if(this._isDisposed){return}this.unbind();this._isDisposed=true}})})();